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
Comments
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 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. |
I would also output on stdout something like "GOPATH env variable is undefined, using default (/home/user/go)" |
Resolved in #87. |
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?
The text was updated successfully, but these errors were encountered: