Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
321ede78
Commit
321ede78
authored
Aug 06, 2013
by
Kyle Lemons
Committed by
Rob Pike
Aug 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flag: document the zero value of FlagSet
R=golang-dev, r CC=golang-dev
https://golang.org/cl/12403043
parent
034d5fcc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
flag.go
src/pkg/flag/flag.go
+13
-3
No files found.
src/pkg/flag/flag.go
View file @
321ede78
...
...
@@ -256,7 +256,8 @@ const (
PanicOnError
)
// A FlagSet represents a set of defined flags.
// A FlagSet represents a set of defined flags. The zero value of a FlagSet
// has no name and has ContinueOnError error handling.
type
FlagSet
struct
{
// Usage is the function called when an error occurs while parsing flags.
// The field is a function (not a method) that may be changed to point to
...
...
@@ -391,7 +392,11 @@ func PrintDefaults() {
// defaultUsage is the default function to print a usage message.
func
defaultUsage
(
f
*
FlagSet
)
{
fmt
.
Fprintf
(
f
.
out
(),
"Usage of %s:
\n
"
,
f
.
name
)
if
f
.
name
==
""
{
fmt
.
Fprintf
(
f
.
out
(),
"Usage:
\n
"
)
}
else
{
fmt
.
Fprintf
(
f
.
out
(),
"Usage of %s:
\n
"
,
f
.
name
)
}
f
.
PrintDefaults
()
}
...
...
@@ -658,7 +663,12 @@ func (f *FlagSet) Var(value Value, name string, usage string) {
flag
:=
&
Flag
{
name
,
usage
,
value
,
value
.
String
()}
_
,
alreadythere
:=
f
.
formal
[
name
]
if
alreadythere
{
msg
:=
fmt
.
Sprintf
(
"%s flag redefined: %s"
,
f
.
name
,
name
)
var
msg
string
if
f
.
name
==
""
{
msg
=
fmt
.
Sprintf
(
"flag redefined: %s"
,
name
)
}
else
{
msg
=
fmt
.
Sprintf
(
"%s flag redefined: %s"
,
f
.
name
,
name
)
}
fmt
.
Fprintln
(
f
.
out
(),
msg
)
panic
(
msg
)
// Happens only if flags are declared with identical names
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment