Golang flag.Getter type example
package flag
Getter is an interface that allows the contents of a Value to be retrieved. It wraps the Value interface, rather than being part of it, because it appeared after Go 1 and its compatibility rules. All Value types provided by this package satisfy the Getter interface.
Golang flag.Getter type usage example
cfg := config.Config{
Verbosity: (*flagset.Lookup("verbosity")).Value.(flag.Getter).Get().(int),
EtcdServers: (*flagset.Lookup("etcd_servers")).Value.(flag.Getter).Get().(stringSlice),
EtcdKeyPrefix: (*flagset.Lookup("etcd_key_prefix")).Value.(flag.Getter).Get().(string),
EtcdKeyFile: (*flagset.Lookup("etcd_keyfile")).Value.(flag.Getter).Get().(string),
EtcdCertFile: (*flagset.Lookup("etcd_certfile")).Value.(flag.Getter).Get().(string),
}
Reference :
Advertisement
Something interesting
Tutorials
+5.8k Javascript : How to replace HTML inside <div>?
+6.4k Golang : How to search a list of records or data structures
+12.5k Golang : HTTP response JSON encoded data
+11.7k Golang : Calculations using complex numbers example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+15.3k nginx: [emerg] unknown directive "ssl"
+12.2k Golang : Get remaining text such as id or filename after last segment in URL path
+14.3k Golang : How to shuffle elements in array or slice?
+29.5k Golang : How to create new XML file ?
+19.4k Golang : How to count the number of repeated characters in a string?
+10.5k Golang : Create matrix with Gonum Matrix package example
+10.9k Golang : Create Temporary File