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

Unified Diff: logdog/common/types/streamaddr.go

Issue 2895233004: [logdog/common/types] make StreamAddr implement flag.Value. (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | logdog/common/types/streamaddr_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/common/types/streamaddr.go
diff --git a/logdog/common/types/streamaddr.go b/logdog/common/types/streamaddr.go
index 53d1018e4ee2f6f1f6fc59512a1aebdb32b70039..ac17da1f9bd8ae94219f9efe2c1bf965aa6f22ee 100644
--- a/logdog/common/types/streamaddr.go
+++ b/logdog/common/types/streamaddr.go
@@ -5,6 +5,7 @@
package types
import (
+ "flag"
"net/url"
"strings"
@@ -26,6 +27,18 @@ type StreamAddr struct {
Path StreamPath
}
+var _ flag.Value = (*StreamAddr)(nil)
+
+// Set implements flag.Value
+func (s *StreamAddr) Set(v string) error {
+ a, err := ParseURL(v)
+ if err != nil {
+ return err
+ }
+ *s = *a
+ return nil
+}
+
// String returns a string representation of this address.
func (s *StreamAddr) String() string { return s.URL().String() }
« no previous file with comments | « no previous file | logdog/common/types/streamaddr_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698