README: update TextUnmarshaler example
Values are much more convenient to use in argument structs, so update README to use them instead of pointers in the example as we now support this. Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
This commit is contained in:
parent
f1aabd5026
commit
a6af419fff
|
@ -288,10 +288,10 @@ func (n *NameDotName) MarshalText() (text []byte, err error) {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var args struct {
|
var args struct {
|
||||||
Name *NameDotName
|
Name NameDotName
|
||||||
}
|
}
|
||||||
// set default
|
// set default
|
||||||
args.Name = &NameDotName{"file", "txt"}
|
args.Name = NameDotName{"file", "txt"}
|
||||||
arg.MustParse(&args)
|
arg.MustParse(&args)
|
||||||
fmt.Printf("%#v\n", args.Name)
|
fmt.Printf("%#v\n", args.Name)
|
||||||
}
|
}
|
||||||
|
@ -305,10 +305,10 @@ Options:
|
||||||
--help, -h display this help and exit
|
--help, -h display this help and exit
|
||||||
|
|
||||||
$ ./example
|
$ ./example
|
||||||
&main.NameDotName{Head:"file", Tail:"txt"}
|
main.NameDotName{Head:"file", Tail:"txt"}
|
||||||
|
|
||||||
$ ./example --name=foo.bar
|
$ ./example --name=foo.bar
|
||||||
&main.NameDotName{Head:"foo", Tail:"bar"}
|
main.NameDotName{Head:"foo", Tail:"bar"}
|
||||||
|
|
||||||
$ ./example --name=oops
|
$ ./example --name=oops
|
||||||
Usage: example [--name NAME]
|
Usage: example [--name NAME]
|
||||||
|
|
Loading…
Reference in New Issue