This code parse command-line arguments. If I type "/netstat -c /etc/config -I eth0", it should is :" c /etc/config i eth0", but it's not . Terminal output is :
c configfile
c interface
./netstat -c /etc/config -i eth0
c configfile
c interface
Code is as below:
package main
import (
"flag"
"fmt"
)
type CmdSt struct {
configPtr string
interfacePtr string
}
var cmdSt CmdSt
func usage() {
cmdSt.configPtr = *flag.String("c", "configfile", "configure file to parse ")
cmdSt.interfacePtr = *flag.String("i", "interface", "capture network interface")
/*
a := flag.String("c", "configfile", "configure file to parse ")
b := flag.String("i", "interface", "capture network interface")
*/
flag.Parse()
fmt.Println("c", cmdSt.configPtr)
fmt.Println("i", cmdSt.interfacePtr)
/*
fmt.Println("c:", *a)
fmt.Println("i:", *b)
*/
}
func main() {
usage()
}