Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Array type causes panic #2

Open
mofirouz opened this issue May 14, 2017 · 0 comments
Open

Array type causes panic #2

mofirouz opened this issue May 14, 2017 · 0 comments

Comments

@mofirouz
Copy link

mofirouz commented May 14, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant