We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
so i have this
cli myCommand -myflag args[]string
and i have f for my shorthand when i use the name it works but when i was using
cli myCommand -f args[]string
it will directly throw panic panic: runtime error: index out of range [0] with length 0
panic: runtime error: index out of range [0] with length 0
myCommand:
RUN: afunction
func init(){ var s string rootCmd.AddCommand(myCommand) myCommand.Flags().StringVarP(&s, "myflag", "f", "", "des") err := myCommand.MarkFlagRequired("myflag") ... }
func afunction(cmd *cobra.Command, args []string){ }
in the end, my solution is using myCommand.DisableFlagParsing=true, and use the args[1] as input
but i wonder why it throws panic while using shorthand
The text was updated successfully, but these errors were encountered:
I believe your s variable must be global
s
Sorry, something went wrong.
no, it isnt, and btw even if i used that variable as global, the name still works fine, the shorthand still not working
No branches or pull requests
so i have this
and i have f for my shorthand
when i use the name it works
but when i was using
it will directly throw panic
panic: runtime error: index out of range [0] with length 0
myCommand:
in the end, my solution is using myCommand.DisableFlagParsing=true, and use the args[1] as input
but i wonder why it throws panic while using shorthand
The text was updated successfully, but these errors were encountered: