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

Add $GOPATH/bin to $PATH #14

Open
lmittmann opened this issue Aug 16, 2019 · 8 comments
Open

Add $GOPATH/bin to $PATH #14

lmittmann opened this issue Aug 16, 2019 · 8 comments
Assignees

Comments

@lmittmann
Copy link

@lmittmann lmittmann commented Aug 16, 2019

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.

@geoah

This comment has been minimized.

Copy link

@geoah geoah commented Aug 16, 2019

GOBIN would be a better choice I think for this

@lmittmann

This comment has been minimized.

Copy link
Author

@lmittmann lmittmann commented Aug 16, 2019

$GOBIN could be used as well, but it also needs to be added to $PATH. Since go env GOBIN is not set and $GOPATH/bin is the default installation path it's just simpler to add the default path to $PATH.

@damccorm

This comment has been minimized.

Copy link
Contributor

@damccorm damccorm commented Aug 19, 2019

I think this should probably be resolved together with #12. Given my most recent comment in that issue, are you ok with closing here and following up there?

@damccorm damccorm self-assigned this Aug 19, 2019
aslakknutsen added a commit to Maistra/istio-workspace that referenced this issue Aug 20, 2019
@lmittmann

This comment has been minimized.

Copy link
Author

@lmittmann lmittmann commented Aug 23, 2019

@damccorm Let's track this issue here, as it seems like #12 is quite fuzzy.

@mvdan

This comment has been minimized.

Copy link

@mvdan mvdan commented 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.

jakewright added a commit to jakewright/home-automation that referenced this issue Sep 24, 2019
As stated in this issue, you can't run tools installed using go get without first updating $PATH.
actions/setup-go#14

Also add -set_exit_status to make golint return 1 if any issues are found.
https://github.com/golang/lint/blob/master/golint/golint.go#L24
@Thiht Thiht mentioned this issue Sep 26, 2019
nbari added a commit to immortal/immortal that referenced this issue Oct 20, 2019
fty4 added a commit to taskmedia/muteOnStartup that referenced this issue Nov 5, 2019
@leighmcculloch

This comment has been minimized.

Copy link

@leighmcculloch leighmcculloch commented Nov 19, 2019

You can avoid this issue by instead using the actions container param to run all the commands in the official golang Docker image. You can see what that looks like here:
https://github.com/stellar/go-xdr/blob/3aa3546/.github/workflows/build.yml

@mvdan

This comment has been minimized.

Copy link

@mvdan mvdan commented Nov 19, 2019

@leighmcculloch I assume that won't work for testing on mac and windows, though, so fixing this bug is still very useful.

@sanemat

This comment has been minimized.

Copy link

@sanemat sanemat commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.