Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Arg.md
Args.md
Bool.md
BoolVar.md
Duration.md
DurationVar.md
FlagSetArg.md
FlagSetArgs.md
FlagSetBool.md
FlagSetBoolVar.md
FlagSetDuration.md
FlagSetFloat64.md
FlagSetFloat64Var.md
FlagSetInit.md
FlagSetInt.md
FlagSetInt64.md
FlagSetInt64Var.md
FlagSetIntVar.md
FlagSetLookup.md
FlagSetNArg.md
FlagSetNFlag.md
FlagSetParse.md
FlagSetParsed.md
FlagSetPrintDefaults.md
FlagSetSet.md
FlagSetSetOutput.md
FlagSetString.md
FlagSetStringVar.md
FlagSetUint.md
FlagSetUint64.md
FlagSetUint64Var.md
FlagSetUintVar.md
FlagSetVar.md
FlagSetVisit.md
FlagSetVisitAll.md
Float64.md
Float64Var.md
Int.md
Int64.md
Int64Var.md
IntVar.md
Lookup.md
NArg.md
NFlag.md
NewFlagSet.md
Parse.md
Parsed.md
PrintDefaults.md
README.md
Set.md
String.md
StringVar.md
Uint.md
Uint64.md
Uint64Var.md
UintVar.md
Var.md
Visit.md
VisitAll.md

README.md

flag包使用详解

##概述 flag包提供了一系列解析命令行参数的功能接口

###Variables

var (
  CommandLine = NewFlagSet(os.Args[0], ExitOnError)
  ErrHelp     = errors.New("flag: help requested")
  Usage       = func() {
    fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
    PrintDefaults()
  }
)

##包函数列表

type Flag

type Flag struct {
        Name     string // name as it appears on command line
        Usage    string // help message
        Value    Value  // value as set
        DefValue string // default value (as text); for usage message
}

type FlagSet

type FlagSet struct {
        Usage func()
}

type Getter

type Getter interface {
        Value
        Get() interface{}
}

type Value

type Value interface {
        String() string
        Set(string) error
}