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

--pkg-name is needed? #901

Closed
pookah-net opened this issue Jul 6, 2019 · 8 comments
Closed

--pkg-name is needed? #901

pookah-net opened this issue Jul 6, 2019 · 8 comments

Comments

@pookah-net
Copy link

pookah-net commented Jul 6, 2019

Hi, I tried using the following: cobra init github.com/pookah-net/test, from go/src, as specified in the README, to create a new Golang project using Cobra, and it kept telling me Error: required flag(s) "pkg-name" not set and giving me the help text.

I finally (!) figured out that cobra init --pkg-name github.com/pookah-net/test was needed, instead. Is it supposed to be that way?

(Oh, it didn't create the src/github.com/pookah-net/test folder. Instead, it created src/cmd/root.go, and src/main.go and src/LICENSE files and folders!)

Thanks
Ian

@umarcor
Copy link
Contributor

umarcor commented Jul 6, 2019

Hi @pookah-net! This is being addressed in #878 nad #888. #891 is also related.

To achieve the behaviour you expect, you need to use either:

cobra init ${GOPATH}/src/github.com/pookah-net/test --pkg-name=github.com/pookah-net/test

or

mkdir github.com/pookah-net/test
cd github.com/pookah-net/test
cobra init --pkg-name=github.com/pookah-net/test

@jharshman, would cobra init work in the second case, provided that it is being executed from ${GOPATH}/src/github.com/pookah-net/test?

@pookah-net
Copy link
Author

Ah, I see! I must have used the wrong search terms, because I didn't see those others.

Thanks!

@jharshman
Copy link
Collaborator

jharshman commented Jul 8, 2019

@umarcor, yes but would still require --pkg-name

@pookah-net documentation on the cobra generator is being updated. In the meantime you can refer to the issues that @umarcor linked as well as #817

@umarcor
Copy link
Contributor

umarcor commented Jul 8, 2019

@umarcor, yes but would still require --pkg-name

So, GOPATH is completely deprecated? I.e, even if cobra init is executed from a 'valid' and empty location (i.e. ${GOPATH}/src/github.com/pookah-net/test), it will not infer pkg-name automatically? I'm not suggesting it is wrong, I just want to be sure about it.

@jharshman
Copy link
Collaborator

@umarcor correct, the generator no longer cares about the GOPATH.

@umarcor
Copy link
Contributor

umarcor commented Jul 8, 2019

@jharshman, thanks!

@pookah-net, can you please close this issue? I believe that it is solved already.

@pookah-net
Copy link
Author

Thanks!

@ahmedatgithub
Copy link

you'd think a cli generator should not have issues with it's own cli :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants