Skip to content

Instantly share code, notes, and snippets.

@confluentgist
Last active April 22, 2020 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save confluentgist/01bfcd69ab33bc204df48ba1efdff750 to your computer and use it in GitHub Desktop.
Save confluentgist/01bfcd69ab33bc204df48ba1efdff750 to your computer and use it in GitHub Desktop.
Bincover example application
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)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment