-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
area/v2relates to / is being considered for v2relates to / is being considered for v2kind/documentationdescribes a documentation updatedescribes a documentation updatestatus/claimedsomeone has claimed this issuesomeone has claimed this issuestatus/triagemaintainers still need to look into thismaintainers still need to look into this
Milestone
Description
my urfave/cli version is
( v.2.3.0)
Checklist
- Are you running the latest v2 release? The list of releases is here.
- Did you check the manual for your release? The v2 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
I'm not sure if this is a bug, but the behavior is unexpected.
To reproduce
-
set variable. For examplle,
gcount := 20
-
use pointer for destination
&cli.IntFlag{
Name: "power",
Usage: "count for goroutines",
Destination: &gcount,
DefaultText: "20",
},
- Println in Action
Action: func(context *cli.Context) error {
log.Println(gcount)
return nil
},
example application - https://play.golang.org/p/aXyfZus7pWi
package main
import (
"log"
"os"
"github.com/urfave/cli/v2"
)
func main() {
gcount := 20
app := &cli.App{
Name: "leviathan",
Usage: "pentest util",
UsageText: "leviathan [command options] address (ip or host)",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "power",
Usage: "count for goroutines",
Destination: &gcount,
DefaultText: "20",
},
},
Action: func(context *cli.Context) error {
log.Println(gcount)
return nil
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
Observed behavior
gcount=0
Expected behavior
gcount=20
PS
After reading the documentation, I realized that I had to do this
Flags: []cli.Flag{
&cli.IntFlag{
Name: "power",
Usage: "count for goroutines",
//Destination: &gcount,
DefaultText: "20",
Value: 20,
},
},
Action: func(context *cli.Context) error {
gcount := context.Int("power")
But I still think that the behavior is unexpected in my case.
Metadata
Metadata
Assignees
Labels
area/v2relates to / is being considered for v2relates to / is being considered for v2kind/documentationdescribes a documentation updatedescribes a documentation updatestatus/claimedsomeone has claimed this issuesomeone has claimed this issuestatus/triagemaintainers still need to look into thismaintainers still need to look into this