Last active
April 22, 2020 17:55
-
-
Save confluentgist/01bfcd69ab33bc204df48ba1efdff750 to your computer and use it in GitHub Desktop.
Bincover example application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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