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 information how to properly set up checked-out code with GO... env variables

See original GitHub issue

Most basic setup with the following steps:

- uses: actions/checkout@v2
...
- uses: actions/setup-go@v2

will fail during dep ensure or go test ./... :

/home/runner/work/myproject/myproject is not within a known GOPATH/src

I must admit that with a little bit of searching I couldn’t easily configure it. Currently it starts with empty directories:

/home/runner/go
/home/runner/go/bin

The code after checkout is in:

/home/runner/work/REPOSITORY/REPOSITORY

It would be worth adding some instructions on how to modify the “checkout” step or how to set environment variables or what shell commands to execute to make it all work.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
januszmcommented, Jan 28, 2021

I got it to work with this yml:

env:
  GOPATH: ${{ github.workspace }}
  GOBIN: ${{ github.workspace }}/bin
defaults:
  run:
    working-directory: ${{ env.GOPATH }}/src/myproject
steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 1
      path: ${{ env.GOPATH }}/src/myproject
  - name: Set up Go
    uses: actions/setup-go@v2
    with:
      go-version: ...

The key was to set this: “working-directory: ${{ env.GOPATH }}/src/myproject” and be consistent. An equivalent of Travis’s go_import_path is to define path: ${{ env.GOPATH }}/src/myproject for checkout and working-directory

1reaction
longwuyuancommented, Feb 4, 2021

my problem turned out to be unique for the codebase in question https://github.com/kubernetes/kube-openapi/issues/225

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Environment Variables in Go | by Wei-Meng Lee
In Windows, you use the set command to view the list of environment variables currently defined. set. If you want to set a...
Read more >
Working With Environment Variables in Go | TutorialEdge.net
Using environment variables is an excellent way to simplify a number of different aspects such as handling credentials across various different ...
Read more >
How to Write Go Code (with GOPATH)
The command go env GOPATH prints the effective current GOPATH ; it prints the default location if the environment variable is unset. For...
Read more >
How to use GitHub Actions environment variables - Snyk
This hands-on article discusses the environment variables available within GitHub Actions and when we should use them.
Read more >
Use Environment Variable in your next Golang Project
Just add the code at the end of the os package in the main function. Viper Package. Viper is one of the most...
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