【发布时间】:2020-11-06 18:15:45
【问题描述】:
我将示例 github 操作设置到我的存储库。 sn-p 来了。
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。
【问题讨论】:
-
go run可能有效,但问题在于go get -v -t -d ./...。你的<repo-name>是私人的吗? -
感谢您的回复。是的。我的存储库是私有的。
-
看起来 actions/checkout@v2 没有将你的代码输出到 GOPATH 中,并且名称表明它期望克隆一个 module。如果您可以转换为模块,这将简单得多。否则,您必须确保您在 GOPATH 中签出到正确的位置。
-
谢谢您的回复。如何将私有仓库转换为模块?
标签: go github-actions