Golang flag.NFlag() function example
package flag
NFlag returns the number of command-line flags that have been set.
Golang flag.NFlag() function usage example
...
func main() {
flag.Parse()
if flag.NFlag() == 0 {
fmt.Println("Usage : thisprogramname filename")
os.Exit(1)
}
...
Reference :
See also : Golang flag.NArg() function example
Advertisement
Something interesting
Tutorials
+12.1k Golang : Clean formatting/indenting or pretty print JSON result
+6.1k Golang : How to verify input is rune?
+6.1k nginx : force all pages to be SSL
+11.7k Golang : Surveillance with web camera and OpenCV
+6.9k Golang : Join lines with certain suffix symbol example
+16k Golang : Read a file line by line
+3.5k Golang : Fix go-cron set time not working issue
+4.8k Unix/Linux : How to pipe/save output of a command to file?
+6.6k Golang : Convert an executable file into []byte example
+5.9k Cash Flow : 50 days to pay your credit card debt
+11.2k Golang : Read until certain character to break for loop
+14k Golang : Human readable time elapsed format such as 5 days ago