我将示例 github 操作设置到我的存储库。片段在这里。
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
但是作业在 Get dependencies
处失败。错误在这里。
package github.com/<organization-account>/<repo-name>/api/domain/repo: cannot find package "github.com/<organization-account>/<repo-name>/api/domain/repo" in any of:
/opt/hostedtoolcache/go/1.14.4/x64/src/github.com/<organization-account>/<repo-name>/api/domain/repo (from $GOROOT)
/home/runner/go/src/github.com/<organization-account>/<repo-name>/api/domain/repo (from $GOPATH)
当然。当 go run main.go
时,我的代码在本地运行。我有 go.mod
,go.sum
。
最佳答案
This is not a correct answer for the OP, but may help someone reaching here from searching.
在您的 go 项目的根目录中:
go mod init
go mod tidy
提交并推送到 github,它现在应该可以工作了。
关于go - Github 操作 : golang cannot find package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62945517/