akamensky / argparse

Argparse for golang. Just because `flag` sucks
MIT License
611 stars 62 forks source link

Getting: import cycle not allowed using the example. #92

Closed Briankp closed 3 years ago

Briankp commented 3 years ago

package main

import ( "fmt" "github.com/akamensky/argparse" "os" )

func main() { // Create new parser object parser := argparse.NewParser("print", "Prints provided string to stdout") // Create string flag s := parser.String("s", "string", &argparse.Options{Required: true, Help: "String to print"}) // Parse input err := parser.Parse(os.Args) if err != nil { // In case of error print error and print usage // This can also be done by passing -h or --help flags fmt.Print(parser.Usage(err)) } // Finally print the collected string fmt.Println(*s) }

above is the source

go build first_argparse.go output: imports github.com/akamensky/argparse imports github.com/akamensky/argparse: import cycle not allowed

~/go/src/cmdline_argparse $ go version go version go1.17.1 darwin/amd64

Briankp commented 3 years ago

Not a bug. Just in case if someone runs into this issue, the following commands is how I fixed it:

go clean -cache -modcache -i -r

 go get  github.com/akamensky/argparse