golang 1.7 Compatibility Error
just switch to golang 1.7 , seems that flag pkg has some error with custom flag options.
$ ./gitlab-workhorse -h
Usage of ./gitlab-workhorse:
./gitlab-workhorse [OPTIONS]
Options:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x55b61c]
goroutine 1 [running]:
panic(0x75a360, 0xc420014170)
/home/git/go1.7/src/runtime/panic.go:500 +0x1a1
net/url.(*URL).String(0x0, 0x0, 0x0)
/home/git/go1.7/src/net/url/url.go:675 +0x5c
flag.isZeroValue(0xc420016600, 0xc4200bcac0, 0x15, 0x7c8da9)
/home/git/go1.7/src/flag/flag.go:393 +0x12d
flag.(*FlagSet).PrintDefaults.func1(0xc420016600)
/home/git/go1.7/src/flag/flag.go:467 +0x1d5
flag.(*FlagSet).VisitAll(0xc420060060, 0xc42004bac0)
/home/git/go1.7/src/flag/flag.go:323 +0x67
flag.(*FlagSet).PrintDefaults(0xc420060060)
/home/git/go1.7/src/flag/flag.go:476 +0x46
flag.PrintDefaults()
/home/git/go1.7/src/flag/flag.go:499 +0x2d
main.main.func1()
/home/git/gopath/src/gitlab.com/gitlab-org/gitlab-workhorse/_build/src/gitlab.com/gitlab-org/gitlab-workhorse/main.go:48 +0x176
flag.(*FlagSet).usage(0xc420060060)
/home/git/go1.7/src/flag/flag.go:823 +0x42
flag.(*FlagSet).parseOne(0xc420060060, 0x8, 0x100000000000010, 0xc4200153d0)
/home/git/go1.7/src/flag/flag.go:870 +0xb4c
flag.(*FlagSet).Parse(0xc420060060, 0xc42000c430, 0x1, 0x1, 0x0, 0x0)
/home/git/go1.7/src/flag/flag.go:915 +0x60
flag.Parse()
/home/git/go1.7/src/flag/flag.go:943 +0x72
main.main()
/home/git/gopath/src/gitlab.com/gitlab-org/gitlab-workhorse/_build/src/gitlab.com/gitlab-org/gitlab-workhorse/main.go:50 +0x68
i track down to the pkg flag private method 'isZeroValue'
-func isZeroValue(value string) bool {
+func isZeroValue(flag *Flag, value string) bool {
+ // Build a zero value of the flag's Value type, and see if the
+ // result of calling its String method equals the value passed in.
+ // This works unless the Value type is itself an interface type.
+ typ := reflect.TypeOf(flag.Value)
+ var z reflect.Value
+ if typ.Kind() == reflect.Ptr {
+ z = reflect.New(typ.Elem())
+ } else {
+ z = reflect.Zero(typ)
+ }
+ if value == z.Interface().(Value).String() {
+ return true
+ }
+
seems golang1.7 use reflect pkg to determin whether a flag value is zero value.
so giltab-workhorse/urlflag.go might have some issue.
func URLFlag(name string, value *url.URL, usage string) **url.URL {
f := &urlFlag{value}
flag.CommandLine.Var(f, name, usage)
return &f.URL
}
but i can't find out the reason, so here you are.