Skip to content

Conversation

@jlisthood
Copy link
Contributor

@jlisthood jlisthood commented May 11, 2022

If you call cmd.Do programmatically more than once, it panics on the 2nd run due to this error:

panic: upload flag redefined: dry-run

goroutine 1 [running]:
github.com/spf13/pflag.(*FlagSet).AddFlag(0xc0005b1300, 0xc0001243c0)
        external/com_github_spf13_pflag/flag.go:848 +0x825
github.com/spf13/pflag.(*FlagSet).VarPF(0xc0005b1300, 0x5122970, 0xc0005cef19, 0x4e6bd3d, 0x7, 0x0, 0x0, 0x4e9006b, 0x24, 0xc0005cef19)
        external/com_github_spf13_pflag/flag.go:831 +0x10b
github.com/spf13/pflag.(*FlagSet).BoolVarP(0xc0005b1300, 0xc0005cef19, 0x4e6bd3d, 0x7, 0x0, 0x0, 0x0, 0x4e9006b, 0x24)
        external/com_github_spf13_pflag/bool.go:55 +0x97
github.com/spf13/pflag.(*FlagSet).BoolP(...)
        external/com_github_spf13_pflag/bool.go:80
github.com/kyleconroy/sqlc/internal/cmd.Do(0xc00003c210, 0x0, 0x0, 0x5119220, 0xc000010010, 0x5119260, 0xc000010018, 0x5119260, 0xc000010020, 0x0)
        external/com_github_kyleconroy_sqlc/internal/cmd/cmd.go:32 +0x2e5
main.main()

To avoid have redefined flags, we can add the upload dry-run flag in the init() function instead.

This fixes #1616

@kyleconroy kyleconroy merged commit 996a73a into sqlc-dev:main May 12, 2022
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

Successfully merging this pull request may close these issues.

Running cmd.Do twice will cause a panic due to redefined flag

2 participants