uber-go / flagoverride Goto Github PK
View Code? Open in Web Editor NEWAn automatic way of creating command line options to override fields from a struct.
License: MIT License
An automatic way of creating command line options to override fields from a struct.
License: MIT License
Hey there,
Thanks for the compact library. It's super useful. I've encountered a bug that I hope you can fix.
When printing default values (or running --help
), the program panics. I've isolated it down to the use of Db []string
. Removing this field will make the program run fine. This is tested on Mac 10.12.4 with go1.8.1.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x14d4b6b]
goroutine 1 [running]:
nakama/vendor/github.com/uber-go/flagoverride.(*intSlice).String(0xc420116740, 0x1551ca0, 0xc420116740)
vendor/github.com/uber-go/flagoverride/vars.go:210 +0x3b
flag.isZeroValue(0xc42001be00, 0xc420116598, 0x2, 0xc4201165a0)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:395 +0x102
flag.(*FlagSet).PrintDefaults.func1(0xc42001be00)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:469 +0x1b9
flag.(*FlagSet).VisitAll(0xc4200168a0, 0xc4200e3508)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:325 +0x67
flag.(*FlagSet).PrintDefaults(0xc4200168a0)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:478 +0x4f
flag.(*FlagSet).defaultUsage(0xc4200168a0)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:511 +0x8e
flag.(*FlagSet).(flag.defaultUsage)-fm()
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:973 +0x2a
flag.(*FlagSet).usage(0xc4200168a0)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:826 +0x2f
flag.(*FlagSet).parseOne(0xc4200168a0, 0x1, 0x1, 0x0)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:868 +0x200
flag.(*FlagSet).Parse(0xc4200168a0, 0xc42000c3b0, 0x1, 0x1, 0xc420019090, 0x199)
/usr/local/Cellar/go/1.8.1/libexec/src/flag/flag.go:913 +0x60
project/vendor/github.com/uber-go/flagoverride.(*FlagMaker).ParseArgs(0xc4201163a0, 0x158ca80, 0xc420019090, 0xc42000c3b0, 0x1, 0x1, 0xc4200c16a0, 0xc42000e020, 0x182d860, 0xc4200fcb70, ...)
vendor/github.com/uber-go/flagoverride/flags.go:273 +0x236
Config file looks like this:
type config struct {
Name string `yaml:"name" json:"name"`
Port int `yaml:"port" json:"port"`
Db []string `yaml:"db" json:"db"`
}
Thanks.
A small feature request.
It would be great to be able to make the flagset name configurable. Currently, it is statically set to xFlags
.
Moreover, it would be great if we could append additional flags to the flagset without them appearing in the config struct. For instance, things like "verbose" logging that we only ever setup during the application start and affects the log level will never be used anywhere else in the application and are not useful to have in the config struct.
Potentially exporting the fields in FlagMaker
?
Thanks a lot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.