Golang flag.Int() function example
package flag
Int defines an int flag with specified name(1st parameter), default value(2nd parameter), and usage(3rd parameter) string. The return value is the address of an int variable that stores the value of the flag.
Golang flag.Int() function usage example
package main
import (
"flag"
"fmt"
)
func main() {
numberval := flag.Int("number", 108, "is an int")
fmt.Println(flag.Lookup("number")) // print Flag struct
fmt.Println("number value : ", *numberval)
}
Output :
&{number is an int 108 108}
number value
Reference :
Advertisement
Something interesting
Tutorials
+9.2k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+6.8k Golang : Calculate pivot points for a cross
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+7.6k Javascript : Push notifications to browser with Push.js
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+9.3k Golang : Timeout example
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+15.3k Golang : Delete certain files in a directory
+10.2k Golang : How to profile or log time spend on execution?
+12.1k Golang : Split strings into command line arguments
+17.4k Golang : Multi threading or run two processes or more example