Golang flag.Parse() function examples
package flag
Parse parses the command-line flags from os.Args[1:]. Must be called after all flags are defined and before flags are accessed by the program.
Golang flag.Parse() function usage examples
Example 1:
func main() {
community := flag.String("community", "public", "community program")
host := flag.String("host", "127.0.0.1", "host")
flag.Parse()
...
Example 2:
func main() {
flag.Parse()
if flag.NArg() != 1 {
log.Fatal("filename not specified")
}
filename = flag.Args()[0]
....
Reference :
Advertisement
Something interesting
Tutorials
+9.3k Golang : How to get username from email address
+9.1k Golang : Simple histogram example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+13.9k Golang : convert(cast) string to float value
+16.4k Golang : Test floating point numbers not-a-number and infinite example
+27.2k Golang : Find files by name - cross platform example
+6k Golang : Experimenting with the Rejang script
+11.7k Golang : Gorilla web tool kit secure cookie example
+13.5k Golang : How to get year, month and day?
+22.9k Golang : Gorilla mux routing example
+7.1k Golang : Validate credit card example