Last active
July 2, 2024 04:25
-
-
Save maciakl/b5877bcb8b1ad21e2e798d3da3bff13b to your computer and use it in GitHub Desktop.
Hello World in Go
This file contains 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 ( | |
"os" | |
"fmt" | |
"flag" | |
"path/filepath" | |
) | |
const version = "0.1.0" | |
func main() { | |
var ver bool | |
flag.BoolVar(&ver, "version", false, "display version number and exit") | |
flag.BoolVar(&ver, "v", false, "display version number and exit") | |
flag.Parse() | |
// show version and exit | |
if ver { | |
fmt.Println(filepath.Base(os.Args[0]), "version", version) | |
os.Exit(0) | |
} | |
fmt.Println("Hello World!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment