1

我有一个 Go 项目,我想为我的项目编写一个 Gitlab CI 文件,但我看到加载模块要求时出错。这是我的 gitlab CI 文件:

stages:
  - compile
build:
  stage: compile
  image: golang:1.12
  script:
    - go build -o binary
error :
Running with gitlab-runner 11.8.0 (4745a6f3)
  on Runner #6 e0e0c446
Using Docker executor with image golang:1.12 ...
Pulling docker image golang:1.12 ...
Using docker image sha256:be63d15101cb68aea1841b45201b08a1a486c1a60a029bbf0ddb284ab646b0b7 for golang:1.12 ...
Running on runner-e0e0c446-project-753-concurrent-0 via runner-01.tool.afra.snapp.infra...
Cloning repository...
Cloning into '/builds/Alsopa/echo-training'...
Checking out ab3994cc as develop...
Skipping Git submodules setup
$ go build -o binary
go: finding github.com/labstack/gommon v0.2.9
go: finding github.com/labstack/echo v3.3.10+incompatible
go: finding github.com/go-sql-driver/mysql v1.4.1
go: google.golang.org/appengine@v1.6.1: unrecognized import path "google.golang.org/appengine" (parse https://google.golang.org/appengine?go-get=1: no go-import meta tags ())
go: error loading module requirements
ERROR: Job failed: exit code 1
4

3 回答 3

0

主要错误似乎是:

go: google.golang.org/appengine@v1.6.1: unrecognized import path
 "google.golang.org/appengine" (parse 
 https://google.golang.org/appengine?go-get=1: no go-import meta tags ())

我会尝试在您的 CI 环境中运行go get -v google.golang.org/appenginecurl -v https://google.golang.org/appengine?go-get=1查看它们显示的内容。

这就是我得到的go get -v google.golang.org/appengine

$ go get -v google.golang.org/appengine
Fetching https://google.golang.org/appengine?go-get=1
Parsing meta tags from https://google.golang.org/appengine?go-get=1 (status code 200)
get "google.golang.org/appengine": found meta tag
 get.metaImport{Prefix:"google.golang.org/appengine",
 VCS:"git", RepoRoot:"https://github.com/golang/appengine"}
 at https://google.golang.org/appengine?go-get=1

也许您有一些网络连接、防火墙或 HTTP 代理问题。

于 2019-08-02T18:16:15.993 回答
0

确保上传最后一个 go.sum 文件。在上传到 master 执行 ci 之前go get,上传到 master 并运行 ci。

于 2019-07-25T14:40:38.480 回答
0

您应该在编译之前下载模块。假设您的项目已经有 go modules 文件go.modgo.sum尝试以.gitlab-ci.yml这种方式更新

build:
  stage: compile
  image: golang:1.13
  script:
    - go get -d -v
    - go build -o binary
于 2020-02-13T10:51:14.600 回答