-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d85f45f
commit 206374e
Showing
6 changed files
with
242 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
go1.18.5 | ||
go1.19.1 |
35 changes: 35 additions & 0 deletions
35
generated_src/internal/amalgomated_flag/example_textvar_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package flag_test | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"net" | ||
"os" | ||
) | ||
|
||
func ExampleTextVar() { | ||
fs := flag.NewFlagSet("ExampleTextVar", flag.ContinueOnError) | ||
fs.SetOutput(os.Stdout) | ||
var ip net.IP | ||
fs.TextVar(&ip, "ip", net.IPv4(192, 168, 0, 100), "`IP address` to parse") | ||
fs.Parse([]string{"-ip", "127.0.0.1"}) | ||
fmt.Printf("{ip: %v}\n\n", ip) | ||
|
||
// 256 is not a valid IPv4 component | ||
ip = nil | ||
fs.Parse([]string{"-ip", "256.0.0.1"}) | ||
fmt.Printf("{ip: %v}\n\n", ip) | ||
|
||
// Output: | ||
// {ip: 127.0.0.1} | ||
// | ||
// invalid value "256.0.0.1" for flag -ip: invalid IP address: 256.0.0.1 | ||
// Usage of ExampleTextVar: | ||
// -ip IP address | ||
// IP address to parse (default 192.168.0.100) | ||
// {ip: <nil>} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.