Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when auto-generated config is used #7

Closed
davidscholberg opened this issue May 25, 2020 · 1 comment
Closed

Error when auto-generated config is used #7

davidscholberg opened this issue May 25, 2020 · 1 comment
Assignees

Comments

@davidscholberg
Copy link
Collaborator

Goify appears to choke on the auto-generated config file with the following error output (happens with both help and auth subcommands):

Using config file: /home/dhscholb/.config/goify/config.yaml
ERROR: logging before flag.Parse: F0525 16:51:33.928019  938724 root.go:103] unexpected end of JSON input
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc0000bc000, 0xc000136140, 0x48, 0x9c)
        /home/dhscholb/src/go/src/github.com/golang/glog/glog.go:769 +0xb8
github.com/golang/glog.(*loggingT).output(0xe25600, 0xc000000003, 0xc000129180, 0xdcf7aa, 0x7, 0x67, 0x0)
        /home/dhscholb/src/go/src/github.com/golang/glog/glog.go:720 +0x372
github.com/golang/glog.(*loggingT).printDepth(0xe25600, 0x3, 0x1, 0xc000125c98, 0x1, 0x1)
        /home/dhscholb/src/go/src/github.com/golang/glog/glog.go:646 +0x129
github.com/golang/glog.(*loggingT).print(...)
        /home/dhscholb/src/go/src/github.com/golang/glog/glog.go:637
github.com/golang/glog.Fatal(...)
        /home/dhscholb/src/go/src/github.com/golang/glog/glog.go:1128
github.com/dvdmuckle/goify/cmd.initConfig()
        /home/dhscholb/src/go/src/github.com/dvdmuckle/goify/cmd/root.go:103 +0x3a5
github.com/spf13/cobra.(*Command).preRun(0xc0000e2dc0)
        /home/dhscholb/src/go/src/github.com/spf13/cobra/command.go:872 +0x49
github.com/spf13/cobra.(*Command).execute(0xc0000e2dc0, 0xe41f98, 0x0, 0x0, 0xc0000e2dc0, 0xe41f98)
        /home/dhscholb/src/go/src/github.com/spf13/cobra/command.go:808 +0x145
github.com/spf13/cobra.(*Command).ExecuteC(0xe1c440, 0x43d30a, 0xddeca0, 0xc000000180)
        /home/dhscholb/src/go/src/github.com/spf13/cobra/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/dhscholb/src/go/src/github.com/spf13/cobra/command.go:887
github.com/dvdmuckle/goify/cmd.Execute()
        /home/dhscholb/src/go/src/github.com/dvdmuckle/goify/cmd/root.go:52 +0x31
main.main()
        /home/dhscholb/src/go/src/github.com/dvdmuckle/goify/main.go:21 +0x20

Tested on 4ad9a78 (which is currently master).

@davidscholberg davidscholberg self-assigned this May 25, 2020
@davidscholberg
Copy link
Collaborator Author

https://github.com/dvdmuckle/goify/blob/4ad9a78501db06e9ac93f2788235448a8f427a37/cmd/root.go#L102

Looks like this code is the culprit. It seems there is no default value set for the auth config variable, and as such if you're using the auto-generated config, the code will try to unmarshal an empty string.

The config code should be refactored to handle the auto-generated config file gracefully. I'll be closing this issue and handling the refactor in a separate one.

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

No branches or pull requests

1 participant