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

Cobra and VGO? #756

Closed
andrewmeissner opened this issue Sep 29, 2018 · 6 comments
Closed

Cobra and VGO? #756

andrewmeissner opened this issue Sep 29, 2018 · 6 comments

Comments

@andrewmeissner
Copy link

I wonder if I'm maybe missing something...

When I run cobra help init, this is what I see:

PS C:\Users\Andrew> cobra help init
Using config file: C:\Users\Andrew\.cobra.yaml
Initialize (cobra init) will create a new application, with a license
and the appropriate structure for a Cobra-based CLI application.

  * If a name is provided, it will be created in the current directory;
  * If no name is provided, the current directory will be assumed;
  * If a relative path is provided, it will be created inside $GOPATH
    (e.g. github.com/spf13/hugo);
  * If an absolute path is provided, it will be created;
  * If the directory already exists but is empty, it will be used.

Init will not use an existing directory with contents.

If I'm reading that correctly, I should be able to run cobra init myApp and have cobra create the structure in the current directory. This isn't the case.

PS C:\Users\Andrew\Desktop\definitelyNotGOPATH> pwd

Path
----
C:\Users\Andrew\Desktop\definitelyNotGOPATH


PS C:\Users\Andrew\Desktop\definitelyNotGOPATH> cobra init myApp
Using config file: C:\Users\Andrew\.cobra.yaml
Your Cobra application is ready at
C:\Users\Andrew\go\src\myApp.

Give it a try by going there and running `go run main.go`.
Add commands to it by running `cobra add [cmdname]`.

PS C:\Users\Andrew\Desktop\definitelyNotGOPATH> echo $env:GOPATH
C:\Users\Andrew\go

PS C:\Users\Andrew\Desktop\definitelyNotGOPATH> cobra init .\rightHerePlease
Using config file: C:\Users\Andrew\.cobra.yaml
Error: Cobra supports project only within $GOPATH: Rel: can't make C:\Users\Andrew\Desktop\definitelyNotGOPATH\rightHerePlease relative to

It seems to always create it in the GOPATH. I'm hoping to be able to use go 1.11's dependency manager (vgo) with cobra, vgo doesn't work in the GOPATH and it looks like cobra only works in the GOPATH. Am I missing something blazingly apparent? If not, are there plans to make cobra compatible with go 1.11's built in dependency manager?

Thanks!

@jharshman
Copy link
Collaborator

Cobra generator only works in your GOPATH. Since I was moving from dep to modules (vgo), I just generated what I needed on my project in the GOPATH and copied it over. Hacky but it works.

@andrewmeissner
Copy link
Author

@jharshman that will work for me on a personal project, but for my work projects that's not really an option. Other people shouldn't have to deal with that nuance.

Additionally, Go's roadmap includes completely abandoning the use of a GOPATH, so I guess I'm wondering if cobra plans to make any necessary changes to stay relevant. I would hope so because it is an incredibly amazing project! I've used it as well as viper for a great deal of my work projects. :)

@jharshman
Copy link
Collaborator

@andrewmeissner I agree, although I still use that workaround at work :).
I'm sure this isn't a huge change code wise, working on a PR to add support.

@jharshman jharshman mentioned this issue Jan 31, 2019
Merged
@noandrea
Copy link

noandrea commented Feb 3, 2019

Hi, this should also resolve issue #720

@jharshman
Copy link
Collaborator

@noandrea @andrewmeissner all tests have passed on #817 . Just waiting review and merge.
I encourage those interested to pull the branch, build and test drive it if interested.

@andrewmeissner
Copy link
Author

Alt Text

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