Golang Package Version Flag
Here is an example of how to implement a version flag for a go program or binary. Taken from my post with more description here
package main
import (
"flag"
"fmt"
"os"
)
const AppVersion = "1.0.0 beta"
func main() {
version := flag.Bool("v", false, "prints current roxy version")
flag.Parse()
if *version {
fmt.Println(AppVersion)
os.Exit(0)
}
fmt.Println("Hello from main()")
}
Written by mtchavez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Golang
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#