Skip to content

Go get doesn't install the cobra command #204

Closed

Description

@robvdl

Tried "go get github.com/spf13/cobra"

According to the docs there should be a cobra command, but there isn't.

Wen't into cobra source folder and did a "go build" again, nothing was built either, probably because it's not under package "main".

Why do the docs mention a cobra command, yet it the command doesn't get built when you go get cobra??

Activity

  1. eparis commented on Dec 4, 2015

    @eparis
    Collaborator

    I think you need to go get github.com/spf13/cobra/cobra

  2. robvdl commented on Dec 4, 2015

    @robvdl
    Author

    Yeah just found that, thanks, it's in a subfolder

  3. jrodriguezjr commented on Jun 13, 2016

    @jrodriguezjr

    is anyone else seeing this when doing a go get github.com/spf13/cobra/cobra

    # github.com/spf13/cobra
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:369: flag.NoOptDefVal undefined (type *pflag.Flag has no field or method NoOptDefVal)
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:383: flag.NoOptDefVal undefined (type *pflag.Flag has no field or method NoOptDefVal)
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:397: flag.NoOptDefVal undefined (type *pflag.Flag has no field or method NoOptDefVal)
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:599: flags.SetAnnotation undefined (type *pflag.FlagSet has no field or method SetAnnotation)
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:623: flags.SetAnnotation undefined (type *pflag.FlagSet has no field or method SetAnnotation)
    ../../gocode/src/github.com/spf13/cobra/bash_completions.go:629: flags.SetAnnotation undefined (type *pflag.FlagSet has no field or method SetAnnotation)
    ../../gocode/src/github.com/spf13/cobra/command.go:508: c.Flags().ArgsLenAtDash undefined (type *pflag.FlagSet has no field or method ArgsLenAtDash)
    ../../gocode/src/github.com/spf13/cobra/command.go:530: c.Flags().GetBool undefined (type *pflag.FlagSet has no field or method GetBool)
    ../../gocode/src/github.com/spf13/cobra/command.go:1145: c.Flags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)
    ../../gocode/src/github.com/spf13/cobra/command.go:1150: c.PersistentFlags().HasAvailableFlags undefined (type *pflag.FlagSet has no field or method HasAvailableFlags)
    ../../gocode/src/github.com/spf13/cobra/command.go:1150: too many errors
    
  4. eparis commented on Jun 13, 2016

    @eparis
    Collaborator

    @jrodriguezjr go get -u github.com/spf13/cobra/pflag

  5. jrodriguezjr commented on Jun 13, 2016

    @jrodriguezjr

    @eparis That worked. Thanks!

  6. 0x2f0 commented on Jun 24, 2023

    @0x2f0

    I have the similar issue but when I tried to solve the problem with the solution given by @eparis, although it has been way too long since the answer has been posted.
    I got the following error:

    go: downloading github.com/spf13/cobra v1.7.0
    go: module github.com/spf13/cobra@upgrade found (v1.7.0), but does not contain package github.com/spf13/cobra/cobra
    
    

    And I found the solution to the error that I received:
    From this Reddit post
    But when try that solution the cobra gets installed but I cannot use the cobra command as it says, command not recognized.
    I have explained in details about the problem and the steps that I took to solve the problem
    Stack overflow

    I am stuck, Any suggestion or response will be appriciated.
    thank you.

    Update
    I found the answer, which was to add the $GOPATH/bin to the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportQuestions, supporting users, etc.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions