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

v1 bug: Wrong document in Flags. #972

Closed
4 of 7 tasks
18kondo opened this issue Dec 4, 2019 · 2 comments
Closed
4 of 7 tasks

v1 bug: Wrong document in Flags. #972

18kondo opened this issue Dec 4, 2019 · 2 comments
Assignees
Labels
area/v1 relates to / is being considered for v1 kind/bug describes or fixes a bug status/triage maintainers still need to look into this

Comments

@18kondo
Copy link

18kondo commented Dec 4, 2019

my urfave/cli version is

2.0.0

Checklist

  • Are you running the latest v1 release? The list of releases is here.
  • Did you check the manual for your release? The v1 manual is here
  • Did you perform a search about this problem? Here's the Github guide about searching.

Dependency Management

  • My project is using go modules.
  • My project is using vendoring.
  • My project is automatically downloading the latest version.
  • I am unsure of what my dependency management setup is.

Describe the bug

Wrong document in flag.

To reproduce

https://github.com/urfave/cli/blob/master/docs/v1/manual.md#flags

package main

import (
  "fmt"
  "log"
  "os"

  "github.com/urfave/cli"
)

func main() {
  app := cli.NewApp()

  app.Flags = []cli.Flag {
    cli.StringFlag{
      Name: "lang",
      Value: "english",
      Usage: "language for the greeting",
    },
  }
}

go build error.

go build
=> cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in array or slice literal:
        cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)

Expected behavior

If you add &, the build was successful.

cli.StringFlag{
↓
&cli.StringFlag{

You should cure the document or revert the v1 changes.

Run go version and paste its output here

go version go1.13 darwin/amd64

Run go env and paste its output here

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/username/Library/Caches/go-build"
GOENV="/Users/username/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/username/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/k-kondo/go/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/username/go/go1.13/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8m/dtc235s11sv585p1wvk068vn2jq9h8/T/go-build161388641=/tmp/go-build -gno-record-gcc-switches -fno-common"
@18kondo 18kondo added status/triage maintainers still need to look into this kind/bug describes or fixes a bug area/v1 relates to / is being considered for v1 labels Dec 4, 2019
@18kondo 18kondo changed the title v1 bug: Wrong document in flag v1 bug: Wrong document in flag. Dec 4, 2019
@asahasrabuddhe
Copy link
Member

There seems to be some confusion here. Your code indicates the use of v1 but the error and the suggested fix indicates the use of v2.

If you want to use v2, please import github.com/urfave/cli/v2 and refer to the v2 manual here.

Could you please share your go.mod file? It would help me help you better.

@18kondo
Copy link
Author

18kondo commented Dec 5, 2019

Thank you for your answer.
I have used v1 so far, but when I updated, an error occurred, so I will use v2 in the future.

I'm sorry. I don't use go mod and can't share.

@18kondo 18kondo changed the title v1 bug: Wrong document in flag. v1 bug: Wrong document in Flags. Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v1 relates to / is being considered for v1 kind/bug describes or fixes a bug status/triage maintainers still need to look into this
Projects
None yet
Development

No branches or pull requests

4 participants