Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: common/flag/stringsetflag/stringsetflag_test.go

Issue 1622553005: Remove log filtering and add stringsetflag. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: error on empty Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/flag/stringsetflag/stringsetflag.go ('k') | common/logging/cloudlog/logging.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/flag/stringsetflag/stringsetflag_test.go
diff --git a/common/flag/stringsetflag/stringsetflag_test.go b/common/flag/stringsetflag/stringsetflag_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..2ba62cfca813eed44bee6c781fd0e89e18103e38
--- /dev/null
+++ b/common/flag/stringsetflag/stringsetflag_test.go
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium 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 stringsetflag
+
+import (
+ "flag"
+ "fmt"
+ "os"
+)
+
+// Example demonstrates how to use flagenum to create bindings for a custom
+// type.
+func Example() {
+ sset := Flag{}
+
+ fs := flag.NewFlagSet("test", flag.ContinueOnError)
+ fs.Var(&sset, "color", "favorite color, may be repeated.")
+ fs.SetOutput(os.Stdout)
+
+ fs.PrintDefaults()
+
+ // Flag parsing.
+ fs.Parse([]string{"-color", "Violet", "-color", "Red", "-color", "Violet"})
+ fmt.Printf("Value is: %s\n", sset)
+
+ fmt.Println("Likes Blue:", sset.Data.Has("Blue"))
+ fmt.Println("Likes Red:", sset.Data.Has("Red"))
+
+ // Output:
+ // -color=: favorite color, may be repeated.
+ // Value is: Red,Violet
+ // Likes Blue: false
+ // Likes Red: true
+}
« no previous file with comments | « common/flag/stringsetflag/stringsetflag.go ('k') | common/logging/cloudlog/logging.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698