添加Golang Cobra包时出现错误,使用Glide。

huangapple go评论81阅读模式
英文:

error adding golang cobra package with glide

问题

我的glide.yaml导入部分是这样的:

import:
  - package: github.com/spf13/cobra

我的代码中有这样的导入语句:

import (
    "github.com/spf13/cobra"
)

但是我遇到了以下错误:

> vendor/github.com/spf13/cobra/command.go:1092: c.lflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
> vendor/github.com/spf13/cobra/command.go:1092: c.Flags().SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
> vendor/github.com/spf13/cobra/command.go:1240: c.parentsPflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)

cobra仓库中的一些问题说,如果pflag包是旧版本,可能会出现这种情况,但在我的情况下,我没有单独安装该包。你知道我做错了什么吗?提前感谢!

英文:

My glide.yaml import section is

import:
  - package: github.com/spf13/cobra

I have

import (
   "github.com/spf13/cobra"
)

in my code.

but I am getting the error

> vendor/github.com/spf13/cobra/command.go:1092: c.lflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
> vendor/github.com/spf13/cobra/command.go:1092: c.Flags().SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
> vendor/github.com/spf13/cobra/command.go:1240: c.parentsPflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)

couples of issues on cobra repo says that can happen if pflag package is old version but in my case don't have that package installed separately.
any idea what am I doing wrong? thanks in advance!

答案1

得分: 1

这是有关Glide缓存未更新的问题,导致安装了旧版本的pflag包。更详细的信息请参考:https://github.com/spf13/cobra/issues/420

英文:

It was problem with glide cache not updating why old version of pflag package was getting installed. More detailed info: https://github.com/spf13/cobra/issues/420

huangapple
  • 本文由 发表于 2017年4月22日 04:45:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/43551721.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定