diff options
author | Robert Griesemer <gri@golang.org> | 2008-10-24 14:05:42 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2008-10-24 14:05:42 -0700 |
commit | ef963ad2f111877cb904f51aa607efb75d851272 (patch) | |
tree | 8d785e72f1b849a364b9cdec95a3400d3ddf2bd6 /src/lib | |
parent | 045ecdb327032f329edee0d9d197724d568f3a6f (diff) | |
download | golang-ef963ad2f111877cb904f51aa607efb75d851272.tar.gz |
- set initial value in flag variable if provided
R=r
DELTA=10 (9 added, 0 deleted, 1 changed)
OCL=17806
CL=17812
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/flag.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/flag.go b/src/lib/flag.go index 7e1cc6d10..e26a905a2 100644 --- a/src/lib/flag.go +++ b/src/lib/flag.go @@ -111,6 +111,9 @@ type BoolValue struct { } func NewBoolValue(val bool, p *bool) *BoolValue { + if p != nil { + *p = val + } return &BoolValue{val, p} } @@ -164,6 +167,9 @@ type IntValue struct { } func NewIntValue(val int64, p *int64) *IntValue { + if p != nil { + *p = val + } return &IntValue{val, p} } @@ -214,6 +220,9 @@ type StringValue struct { } func NewStringValue(val string, p *string) *StringValue { + if p != nil { + *p = val + } return &StringValue{val, p} } @@ -397,7 +406,7 @@ func (f *Flags) ParseOne(index int) (ok bool, next int) } } name := s[num_minuses : len(s)]; - if len(name) == 0 || name[0] == '-' || name[0]=='=' { + if len(name) == 0 || name[0] == '-' || name[0] == '=' { print("bad flag syntax: ", s, "\n"); Usage(); } |