-
-
Save mieitza/11d355d69e1eb5d79084 to your computer and use it in GitHub Desktop.
Parse command line flags 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 ( | |
"flag" | |
"fmt" | |
) | |
var hostName = flag.String("host", "localhost", "Hostname or IP you want to run this service on") | |
var portNumber = flag.Int("port", 8080, "Port you want this service to listen on (default 8080)") | |
func main() { | |
flag.Parse() | |
fmt.Println(*hostName) | |
fmt.Println(*portNumber) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment