[Go] gocron source package implements reading -flag command line parameter acquisition

Call flag can be easily acquired packet transmission command line parameters, such as may be implemented similar nginx execution program obtains a target to perform different operations of command line parameters

main Package 

Import ( 
    " In Flag " 
    " FMT " 
    " OS " 
) 

FUNC main () { 
    var H BOOL 
    var C, S String 
    flag.BoolVar ( & H, " H " , to false , " Help " ) 
    flag.StringVar ( & C, " C " , " the conf / nginx.conf " , " set configuration file: " ) 
    flag.StringVar ( & S, "s", "" , " Management Services: reload | restart | Start | STOP " ) 
    flag.Parse () 
    IF H {
         fmt .Fprintf (os.Stdout, " nginx Version: nginx /% S \ the n- " , " 100.0.0 " ) 
        flag.PrintDefaults () 
    } 
    IF C! = "" {
         FMT .Println ( " -C parameter " , C) 
    } 
    IF S! = "" {
         FMT .Println ( " -s parameter " ,s)
    }
}

Guess you like

Origin www.cnblogs.com/taoshihan/p/11871995.html