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

'undefined' errors during compilation #450

Closed
rabellamy opened this issue May 19, 2017 · 3 comments
Closed

'undefined' errors during compilation #450

rabellamy opened this issue May 19, 2017 · 3 comments
Labels
kind/support Questions, supporting users, etc.

Comments

@rabellamy
Copy link
Contributor

I am receiving the below 'undefined' errors when trying to complile a new Cobra app:

$ go build
# github.com/spf13/cobra
../../spf13/cobra/command.go:419: fs.ShorthandLookup undefined (type *pflag.FlagSet has no field or method ShorthandLookup)
../../spf13/cobra/command.go:1124: c.lflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
../../spf13/cobra/command.go:1124: c.Flags().SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
../../spf13/cobra/command.go:1281: c.parentsPflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)

I was able to narrow it down to two commits using git-bisect:

Debugging with git-bisect

fs.ShorthandLookup undefined (type *pflag.FlagSet has no field or method ShorthandLookup)
4061f41c9aacfb1d66b941fefab8a3e900964217 is the first bad commit
commit 4061f41c9aacfb1d66b941fefab8a3e900964217
Author: Albert Nigmatzianov <albertnigma@gmail.com>
Date:   Fri May 5 08:08:38 2017 +0200

    Use pflag.ShorthandLookup

:100644 100644 bb26d200c0ffa2326dd732fd9eb701c589cdac02 4bf1e241471d9b41716301c85af5b474865d45d9 M      command.go
c.lflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
6202b5942b8f31501d14d8cb192790d8a10302f4 is the first bad commit
commit 6202b5942b8f31501d14d8cb192790d8a10302f4
Author: Albert Nigmatzianov <albertnigma@gmail.com>
Date:   Wed Apr 5 18:44:50 2017 +0200

    Refactor flags mechanisms

    I think It's more obvious now to understand the inheritance of flags.

    Fix #403
    Fix #404

    Performance improvements:
    benchmark                     old ns/op     new ns/op     delta
    BenchmarkInheritedFlags-4     6536          5595          -14.40%
    BenchmarkLocalFlags-4         3193          3235          +1.32%

    benchmark                     old allocs     new allocs     delta
    BenchmarkInheritedFlags-4     49             39             -20.41%
    BenchmarkLocalFlags-4         23             21             -8.70%

    benchmark                     old bytes     new bytes     delta
    BenchmarkInheritedFlags-4     2040          1000          -50.98%
    BenchmarkLocalFlags-4         1008          544           -46.03%

:100644 100644 46887fd7d141d2904137dd0d40fe103bd3b2aada 6c443e7a0025fbc6b858de103381a061275b6612 M      cobra_test.go
:100644 100644 50bd3bb78464f7752643e5e6077574ec37215bbd a4366562f623b6b8b7bcdbe1d6958d9d643d6723 M      command.go

In the meantime I have been developing off of a3cd8ab.

@n10v
Copy link
Collaborator

n10v commented May 19, 2017

Hello!
Try to do go get -u github.com/spf13/pflag or if you use vendoring, update github.com/spf13/pflag package.

@n10v n10v added the kind/support Questions, supporting users, etc. label May 19, 2017
@rabellamy
Copy link
Contributor Author

@BoGeM: Thanks! Will Cobra be having any formal releases in the future?

@n10v
Copy link
Collaborator

n10v commented May 19, 2017

Hopefully. More info you can find in #259 and #440.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Questions, supporting users, etc.
Projects
None yet
Development

No branches or pull requests

2 participants