Cobra: go build fails

Created on 9 Jun 2016  路  6Comments  路  Source: spf13/cobra

I have the latest versions of cobra & pflags.

# github.com/spf13/cobra
./command.go:508: c.Flags().ArgsLenAtDash undefined (type *pflag.FlagSet has no field or method ArgsLenAtDash)
./command.go:1145: c.Flags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)
./command.go:1150: c.PersistentFlags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)
./command.go:1156: c.LocalFlags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)
./command.go:1162: c.InheritedFlags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)

Most helpful comment

Ran into this too (when updating Hugo, which uses Cobra, which uses Pflag).

go get -u github.com/spf13/pflag

This should also work to update all the dependencies of the package you're in and its subdirectories:

go get -u -v ./...

All 6 comments

nvm

@icholy:
I got the same error message, how did you fix the problem? I'm using cobra as vendored dependency with the latest master.

Okay, found the solution myself. I forgot to delete ~/.go/{src/pkg}/github.com/spf13/cobra

@klingtnet I had an old version of pflags. I deleted it and did go-get again.

@icholy Thanks for the reply, I've used cobra as a vendored dependency.

Ran into this too (when updating Hugo, which uses Cobra, which uses Pflag).

go get -u github.com/spf13/pflag

This should also work to update all the dependencies of the package you're in and its subdirectories:

go get -u -v ./...
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukasmalkmus picture lukasmalkmus  路  4Comments

diwakergupta picture diwakergupta  路  5Comments

galileo-pkm picture galileo-pkm  路  6Comments

supershal picture supershal  路  4Comments

jjzcru picture jjzcru  路  3Comments