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

Unexpected behaviour creating a ponzu project #82

Closed
sirikon opened this issue Feb 22, 2017 · 3 comments
Closed

Unexpected behaviour creating a ponzu project #82

sirikon opened this issue Feb 22, 2017 · 3 comments

Comments

@sirikon
Copy link

sirikon commented Feb 22, 2017

Using go1.8 there's a 'default' GOPATH, so, it isn't required to install ponzu and use it.

But ponzu requires to have a GOPATH configured, so it can put inside GOPATH/src the new project.

I think that ponzu should do the same, and fallback to the default GOPATH when using Go 1.8.

@nilslice What do you think?

@nilslice
Copy link
Contributor

That is a good point -- I hadn't considered the case when GOPATH env var wasn't available. I suppose the go tool wouldn't export the default $HOME/go to the system if it's not set (if that's even possible).

I think we still need to check for the GOPATH env var, and use it if it exists because many users will have a custom GOPATH defined. In the event that GOPATH env var is not set, we should use $HOME/go or the Windows equivalent (which I believe is available at os/user.User.HomeDir).

This would be a good function to include in the paths.go file..

import "os/user"

func gopath() (string, error) {
    usr, err := user.Current()
    if err != nil {
        return "", err
    }
    gopath := usr.Current().HomeDir

    if (os.Getenv("GOPATH") == "") {
        gopath = os.Getenv("GOPATH")
    }

    return gopath, nil
}

Does that look right to you? If you have time and would like to add this & implement throughout, please go ahead and make another PR. I have a really tight deadline coming up and won't be able to fully change out all the instances of GOPATH checks in the code until after the weekend.

@sirikon
Copy link
Author

sirikon commented Feb 22, 2017

I would also output on stdout something like "GOPATH env variable is undefined, using default (/home/user/go)"

@nilslice
Copy link
Contributor

nilslice commented Mar 1, 2017

Resolved in #87.

@nilslice nilslice closed this as completed Mar 1, 2017
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

2 participants