I am using dep utility to download and manage go dependencies.
My project is able to be compiled without downloding any additional modules, all are in the vendor folder.
I am using gometalinter to check my code. Running gometalinter locally is working.
However in the github actions, I have this kind of issues:
main.go:6:2:error: cannot find package "github.com/smutel/terraform-provider-netbox/netbox" in any of: (vet) main.go:4:2:error: cannot find package "github.com/hashicorp/terraform-plugin-sdk/plugin" in any of: (vet) main.go:4:2:warning: unused variable or constant could not import github.com/hashicorp/terraform-plugin-sdk/plugin (cannot find package "github.com/hashicorp/terraform-plugin-sdk/plugin" in any of: (varcheck)
Hi @smutel ,
Thank you for being here!
What's your Go version? And what's the $GOPATH and $PATH setting in workflow run? Could you please provide the repo/sample repo here? It will be quite helpful for further investigation. Thanks.
Here is the link to my repo: https://github.com/smutel/terraform-provider-netbox/tree/init-the-project
And the env variables are:
export GOPATH=$HOME/go export GOBIN=$(go env GOPATH)/bin export PATH=$PATH:$GOPATH export PATH=$PATH:$GOBIN
Hi @smutel ,
Thanks for your reply! 'actions/checkout' will checkout the code into Github workspace. You can set it as GOPATH value.
- name: setup env run: | echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)" echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin" shell: bash
And 'go get' command will clone the dependencies to your 'src' folder. I checked directly with below code, reported same error as 'go get -d ./...'.
go get -d github.com/hashicorp/hcl/v2
Please fix the dependency URL to make sure it can be got successfully.
Hope it helps!
You don't need to download go dependencies since they're already in vendor folder. :)
I notice the build is passed in your latest workflow with env setting:
- name: Setup env run: | echo "::set-env name=GOPATH::$(dirname $GITHUB_WORKSPACE)" echo "::add-path::$(dirname $GITHUB_WORKSPACE)/bin" mkdir -p "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel" ln -sf "$GITHUB_WORKSPACE/" "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/terraform-provider-netbox" shell: bash
Could you please help to cofirm whether it's resolved?