Coder Social home page Coder Social logo

Comments (3)

sirikon avatar sirikon commented on April 28, 2024 1

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

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

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.

from ponzu.

nilslice avatar nilslice commented on April 28, 2024

Resolved in #87.

from ponzu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.