github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/api/types/filters/example_test.go (about) 1 package filters // import "github.com/docker/docker/api/types/filters" 2 import "fmt" 3 4 func ExampleArgs_MatchKVList() { 5 args := NewArgs( 6 Arg("label", "image=foo"), 7 Arg("label", "state=running")) 8 9 // returns true because there are no values for bogus 10 b := args.MatchKVList("bogus", nil) 11 fmt.Println(b) 12 13 // returns false because there are no sources 14 b = args.MatchKVList("label", nil) 15 fmt.Println(b) 16 17 // returns true because all sources are matched 18 b = args.MatchKVList("label", map[string]string{ 19 "image": "foo", 20 "state": "running", 21 }) 22 fmt.Println(b) 23 24 // returns false because the values do not match 25 b = args.MatchKVList("label", map[string]string{ 26 "image": "other", 27 }) 28 fmt.Println(b) 29 30 // Output: 31 // true 32 // false 33 // true 34 // false 35 }