mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
api/types/filters: add output to example
Make the example actually do something, and include the output, so that it shows up in the documentation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6743bf3173
commit
3d73d32499
1 changed files with 15 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
package filters // import "github.com/docker/docker/api/types/filters"
|
package filters // import "github.com/docker/docker/api/types/filters"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
func ExampleArgs_MatchKVList() {
|
func ExampleArgs_MatchKVList() {
|
||||||
args := NewArgs(
|
args := NewArgs(
|
||||||
|
@ -6,19 +7,29 @@ func ExampleArgs_MatchKVList() {
|
||||||
Arg("label", "state=running"))
|
Arg("label", "state=running"))
|
||||||
|
|
||||||
// returns true because there are no values for bogus
|
// returns true because there are no values for bogus
|
||||||
args.MatchKVList("bogus", nil)
|
b := args.MatchKVList("bogus", nil)
|
||||||
|
fmt.Println(b)
|
||||||
|
|
||||||
// returns false because there are no sources
|
// returns false because there are no sources
|
||||||
args.MatchKVList("label", nil)
|
b = args.MatchKVList("label", nil)
|
||||||
|
fmt.Println(b)
|
||||||
|
|
||||||
// returns true because all sources are matched
|
// returns true because all sources are matched
|
||||||
args.MatchKVList("label", map[string]string{
|
b = args.MatchKVList("label", map[string]string{
|
||||||
"image": "foo",
|
"image": "foo",
|
||||||
"state": "running",
|
"state": "running",
|
||||||
})
|
})
|
||||||
|
fmt.Println(b)
|
||||||
|
|
||||||
// returns false because the values do not match
|
// returns false because the values do not match
|
||||||
args.MatchKVList("label", map[string]string{
|
b = args.MatchKVList("label", map[string]string{
|
||||||
"image": "other",
|
"image": "other",
|
||||||
})
|
})
|
||||||
|
fmt.Println(b)
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// true
|
||||||
|
// false
|
||||||
|
// true
|
||||||
|
// false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue