Skip to content

Commit

Permalink
增加FlagSet相关函数目录
Browse files Browse the repository at this point in the history
  • Loading branch information
faberliu committed Nov 6, 2014
1 parent ae6e2b6 commit 968cbdd
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
30 changes: 30 additions & 0 deletions flag/NewFlagSet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet

参数列表
- name string flagset的名称
- errorHandling ErrorHandling flagset的错误处理方式,包括`ContinueOnError`:出错仍继续, `ExitOnError`:出错后退出程序,`PanicOnError`:出错后panic三种错误处理方式

返回值
- *FlagSet Flagset指针

功能说明
- 获取一个指定名称和错误处理方式的空FlagSet

代码示例

package main

import (
"flag"
"fmt"
)

func main() {
var myFlagSet = flag.NewFlagSet("myFlagSet", flag.ExitOnError)
fmt.Println(myFlagSet)
}

执行结果

// ./testnewflagset
&{<nil> myFlagSet false map[] map[] [] 1 ?reflect.Value?}
65 changes: 64 additions & 1 deletion flag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,67 @@ flag包提供了一系列解析命令行参数的功能接口
- [func UintVar(p *uint, name string, value uint, usage string)](UintVar.md)
- [func Var(value Value, name string, usage string)](Var.md)
- [func Visit(fn func(*Flag))](Visit.md)
- [func VisitAll(fn func(*Flag))](VisitAll.md)
- [func VisitAll(fn func(*Flag))](VisitAll.md)

### 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
}

- [func Lookup(name string) *Flag](Lookup.md)

### type FlagSet

type FlagSet struct {
Usage func()
}

- [func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet](NewFlagSet.md)
- [func (f *FlagSet) Arg(i int) string](FlagSetArg.md)
- [func (f *FlagSet) Args() []string](FlagSetArgs.md)
- [func (f *FlagSet) Bool(name string, value bool, usage string) *bool](FlagSetBool.md)
- [func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string)](FlagSetBoolVar.md)
- [func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration](FlagSetDuration.md)
- [func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string)](FlagSetDurationVar.md)
- [func (f *FlagSet) Float64(name string, value float64, usage string) *float64](FlagSetFloat64.md)
- [func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string)](FlagSetFloat64Var)
- [func (f *FlagSet) Init(name string, errorHandling ErrorHandling)](FlagSetInit.md)
- [func (f *FlagSet) Int(name string, value int, usage string) *int](FlagSetInt.md)
- [func (f *FlagSet) Int64(name string, value int64, usage string) *int64](FlagSetInt64.md)
- [func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string)](FlagSetInt64Var)
- [func (f *FlagSet) IntVar(p *int, name string, value int, usage string)](FlagSetIntVar)
- [func (f *FlagSet) Lookup(name string) *Flag](FlagSetIntVar.md)
- [func (f *FlagSet) NArg() int](FlagSetNArg.md)
- [func (f *FlagSet) NFlag() int](FlagSetNFlag.md)
- [func (f *FlagSet) Parse(arguments []string) error](FlagSetParse.md)
- [func (f *FlagSet) Parsed() bool](FlagSetParsed.md)
- [func (f *FlagSet) PrintDefaults()](FlagSetPrintDefaults.md)
- [func (f *FlagSet) Set(name, value string) error](FlagSetSet.md)
- [func (f *FlagSet) SetOutput(output io.Writer)](FlagSetSetOutput.md)
- [func (f *FlagSet) String(name string, value string, usage string) *string](FlagSetString.md)
- [func (f *FlagSet) StringVar(p *string, name string, value string, usage string)](FlagSetStringVar.md)
- [func (f *FlagSet) Uint(name string, value uint, usage string) *uint](FlagSetUint.md)
- [func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64](FlagSetUint64.md)
- [func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string)](FlagSetUint64Var.md)
- [func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string)](FlagSetUintVar.md)
- [func (f *FlagSet) Var(value Value, name string, usage string)](FlagSetVar.md)
- [func (f *FlagSet) Visit(fn func(*Flag))](FlagSetVisit.md)
- [func (f *FlagSet) VisitAll(fn func(*Flag))](FlagSetVisitAll.md)

### type Getter

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

### type Value

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

0 comments on commit 968cbdd

Please sign in to comment.