Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
a318f9d3
Commit
a318f9d3
authored
Apr 15, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flag: eliminate unnecessary structs
R=r CC=golang-dev
https://golang.org/cl/872045
parent
fffac807
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
48 deletions
+32
-48
src/pkg/flag/flag.go
src/pkg/flag/flag.go
+32
-48
No files found.
src/pkg/flag/flag.go
View file @
a318f9d3
...
@@ -58,147 +58,131 @@ import (
...
@@ -58,147 +58,131 @@ import (
)
)
// -- Bool Value
// -- Bool Value
type
boolValue
struct
{
type
boolValue
bool
p
*
bool
}
func
newBoolValue
(
val
bool
,
p
*
bool
)
*
boolValue
{
func
newBoolValue
(
val
bool
,
p
*
bool
)
*
boolValue
{
*
p
=
val
*
p
=
val
return
&
boolValue
{
p
}
return
(
*
boolValue
)(
p
)
}
}
func
(
b
*
boolValue
)
Set
(
s
string
)
bool
{
func
(
b
*
boolValue
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atob
(
s
)
v
,
err
:=
strconv
.
Atob
(
s
)
*
b
.
p
=
v
*
b
=
boolValue
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
b
*
boolValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
b
.
p
)
}
func
(
b
*
boolValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
b
)
}
// -- Int Value
// -- Int Value
type
intValue
struct
{
type
intValue
int
p
*
int
}
func
newIntValue
(
val
int
,
p
*
int
)
*
intValue
{
func
newIntValue
(
val
int
,
p
*
int
)
*
intValue
{
*
p
=
val
*
p
=
val
return
&
intValue
{
p
}
return
(
*
intValue
)(
p
)
}
}
func
(
i
*
intValue
)
Set
(
s
string
)
bool
{
func
(
i
*
intValue
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atoi
(
s
)
v
,
err
:=
strconv
.
Atoi
(
s
)
*
i
.
p
=
int
(
v
)
*
i
=
intValue
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
i
*
intValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
.
p
)
}
func
(
i
*
intValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
)
}
// -- Int64 Value
// -- Int64 Value
type
int64Value
struct
{
type
int64Value
int64
p
*
int64
}
func
newInt64Value
(
val
int64
,
p
*
int64
)
*
int64Value
{
func
newInt64Value
(
val
int64
,
p
*
int64
)
*
int64Value
{
*
p
=
val
*
p
=
val
return
&
int64Value
{
p
}
return
(
*
int64Value
)(
p
)
}
}
func
(
i
*
int64Value
)
Set
(
s
string
)
bool
{
func
(
i
*
int64Value
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atoi64
(
s
)
v
,
err
:=
strconv
.
Atoi64
(
s
)
*
i
.
p
=
v
*
i
=
int64Value
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
i
*
int64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
.
p
)
}
func
(
i
*
int64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
)
}
// -- Uint Value
// -- Uint Value
type
uintValue
struct
{
type
uintValue
uint
p
*
uint
}
func
newUintValue
(
val
uint
,
p
*
uint
)
*
uintValue
{
func
newUintValue
(
val
uint
,
p
*
uint
)
*
uintValue
{
*
p
=
val
*
p
=
val
return
&
uintValue
{
p
}
return
(
*
uintValue
)(
p
)
}
}
func
(
i
*
uintValue
)
Set
(
s
string
)
bool
{
func
(
i
*
uintValue
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atoui
(
s
)
v
,
err
:=
strconv
.
Atoui
(
s
)
*
i
.
p
=
uint
(
v
)
*
i
=
uintValue
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
i
*
uintValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
.
p
)
}
func
(
i
*
uintValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
)
}
// -- uint64 Value
// -- uint64 Value
type
uint64Value
struct
{
type
uint64Value
uint64
p
*
uint64
}
func
newUint64Value
(
val
uint64
,
p
*
uint64
)
*
uint64Value
{
func
newUint64Value
(
val
uint64
,
p
*
uint64
)
*
uint64Value
{
*
p
=
val
*
p
=
val
return
&
uint64Value
{
p
}
return
(
*
uint64Value
)(
p
)
}
}
func
(
i
*
uint64Value
)
Set
(
s
string
)
bool
{
func
(
i
*
uint64Value
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atoui64
(
s
)
v
,
err
:=
strconv
.
Atoui64
(
s
)
*
i
.
p
=
uint64
(
v
)
*
i
=
uint64Value
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
i
*
uint64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
.
p
)
}
func
(
i
*
uint64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
i
)
}
// -- string Value
// -- string Value
type
stringValue
struct
{
type
stringValue
string
p
*
string
}
func
newStringValue
(
val
string
,
p
*
string
)
*
stringValue
{
func
newStringValue
(
val
string
,
p
*
string
)
*
stringValue
{
*
p
=
val
*
p
=
val
return
&
stringValue
{
p
}
return
(
*
stringValue
)(
p
)
}
}
func
(
s
*
stringValue
)
Set
(
val
string
)
bool
{
func
(
s
*
stringValue
)
Set
(
val
string
)
bool
{
*
s
.
p
=
val
*
s
=
stringValue
(
val
)
return
true
return
true
}
}
func
(
s
*
stringValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s"
,
*
s
.
p
)
}
func
(
s
*
stringValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s"
,
*
s
)
}
// -- Float Value
// -- Float Value
type
floatValue
struct
{
type
floatValue
float
p
*
float
}
func
newFloatValue
(
val
float
,
p
*
float
)
*
floatValue
{
func
newFloatValue
(
val
float
,
p
*
float
)
*
floatValue
{
*
p
=
val
*
p
=
val
return
&
floatValue
{
p
}
return
(
*
floatValue
)(
p
)
}
}
func
(
f
*
floatValue
)
Set
(
s
string
)
bool
{
func
(
f
*
floatValue
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atof
(
s
)
v
,
err
:=
strconv
.
Atof
(
s
)
*
f
.
p
=
v
*
f
=
floatValue
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
f
*
floatValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
f
.
p
)
}
func
(
f
*
floatValue
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
f
)
}
// -- Float64 Value
// -- Float64 Value
type
float64Value
struct
{
type
float64Value
float64
p
*
float64
}
func
newFloat64Value
(
val
float64
,
p
*
float64
)
*
float64Value
{
func
newFloat64Value
(
val
float64
,
p
*
float64
)
*
float64Value
{
*
p
=
val
*
p
=
val
return
&
float64Value
{
p
}
return
(
*
float64Value
)(
p
)
}
}
func
(
f
*
float64Value
)
Set
(
s
string
)
bool
{
func
(
f
*
float64Value
)
Set
(
s
string
)
bool
{
v
,
err
:=
strconv
.
Atof64
(
s
)
v
,
err
:=
strconv
.
Atof64
(
s
)
*
f
.
p
=
v
*
f
=
float64Value
(
v
)
return
err
==
nil
return
err
==
nil
}
}
func
(
f
*
float64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
f
.
p
)
}
func
(
f
*
float64Value
)
String
()
string
{
return
fmt
.
Sprintf
(
"%v"
,
*
f
)
}
// Value is the interface to the dynamic value stored in a flag.
// Value is the interface to the dynamic value stored in a flag.
// (The default value is represented as a string.)
// (The default value is represented as a string.)
...
...
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