question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add $GOPATH/bin to $PATH

See original GitHub issue

When installing tools via go get (e.g. golint) they can not be ran without adding $GOPATH/bin to $PATH beforehand.

So for using e.g. golint one would need to write a step:

- run: |
    export PATH=$PATH:$(go env GOPATH)/bin
    go get -u golang.org/x/lint/golint
    golint -set_exit_status ./...

It would be cool, if setup-go could already do the export PATH=$PATH:$(go env GOPATH)/bin part, as this is a common need.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:84
  • Comments:25 (6 by maintainers)

github_iconTop GitHub Comments

16reactions
mvdancommented, Sep 3, 2019

I think you’re overthinking this. The official Go docker images simply hard-code PATH, as you can see here: https://github.com/docker-library/golang/blob/3a6407a6ff134ef6a0364ac061b0808f990ea14e/1.13-rc/alpine3.10/Dockerfile#L59-L60

Why not do the same? If anyone wants to set up a custom GOPATH or GOBIN, they can set up a custom PATH too. I’d prefer PATH to be simple and predictable.

12reactions
sanematcommented, Dec 9, 2019

I prefer this solution below. This works on windows, ubuntu, and mac.

    steps:
    - name: setup go
      uses: actions/setup-go@v1
      with:
        go-version: 1.x
    - name: setup env
      run: |
        echo "::set-env name=GOPATH::$(go env GOPATH)"
        echo "::add-path::$(go env GOPATH)/bin"
      shell: bash
    - name: checkout
      uses: actions/checkout@v1
      with:
        fetch-depth: 1
        path: src/github.com/${{ github.repository }}

https://stackoverflow.com/a/59242962/104080

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I SET the GOPATH environment variable on Ubuntu ...
Just add the following lines to ~/.bashrc and this will persist. ... export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin.
Read more >
How to Write Go Code (with GOPATH)
For convenience, add the workspace's bin subdirectory to your PATH : $ export PATH=$PATH:$(go env GOPATH)/bin. The scripts in the rest of this...
Read more >
Setup | GopherSource
Understand your GOPATH. The GOPATH is the location where Go looks for source code, caches packages, etc. · Add GOPATH/bin to your PATH....
Read more >
Installing Go - Play with Go
Add the install target to your profile PATH : $ echo export PATH="/usr/local/go/bin:$PATH" >>$HOME/.profile. Source your profile to test the new settings:
Read more >
Go Path Explained - Medium
In Short The GOPATH is an environment variable that helps Go to look for go source code. go env GOPATH · Can be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found