File: main.go

package info (click to toggle)
golang-github-confluentinc-bincover 0.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 42; sh: 33
file content (39 lines) | stat: -rw-r--r-- 649 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main

import (
	"fmt"
	"os"
	"strconv"

	"github.com/confluentinc/bincover"
)

var (
	// Injected from linker flags like `go build -ldflags "-X main.version=$VERSION" -X ...`
	isTest = "false"
)

func main() {
	isTest, err := strconv.ParseBool(isTest)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	exitCode := 0
	switch len(os.Args) {
	case 2:
		fmt.Printf("Your argument is \"%s\"\n", os.Args[1])
	case 1:
		fmt.Println("Please provide an argument")
		exitCode = 1
	default:
		panic("More than 2 arguments provided! Ahh!")
	}
	if exitCode != 0 {
		if isTest {
			bincover.ExitCode = exitCode
		} else {
			os.Exit(exitCode)
		}
	}
}