我正在尝试升级我的项目以使用Go模块进行依赖项管理。我认识到这是一项新功能/实验功能。我遇到错误:cannot find module providing package
。
我的go.mod
当前显示为:
require (
github.com/bugsnag/bugsnag-go v1.5.1
github.com/bwmarrin/discordgo v0.19.0
github.com/jonas747/dshardmanager v0.0.0-20180911185241-9e4282faed43
)
我的Dockerfile:
FROM golang:1.12-alpine
RUN mkdir /app
WORKDIR /app
ADD src/ /app
ENV CGO_ENABLED=0
# Building requires git because we're pulling a dependency by commit hash
RUN apk add --no-cache --update git \
&& go build ./... \
&& apk del git
CMD ["/app/main"]
构建时失败,并显示:
cannot load github.com/bugsnag/panicwrap: cannot find module providing package github.com/bugsnag/panicwrap
当我查看https://web.archive.org/web/20151128202604/http://aspnetupload.com/Upload-File-POST-HttpWebRequest-WebClient-RFC-1867.aspx时,没有看到go.mod
文件。该错误是否表示此依赖项不支持模块?
答案 0 :(得分:0)
您做错了,因为它可以工作。它不需要go.mod
即可用于基于go.mod
的应用程序:
nrxr at lise in ~/code/src/github.com/nrxr/stack
$ go mod init
go: creating new go.mod: module github.com/nrxr/stack
nrxr at lise in ~/code/src/github.com/nrxr/stack
$ go get github.com/bugsnag/bugsnag-go
go: finding github.com/bugsnag/bugsnag-go v1.5.1
go: downloading github.com/bugsnag/bugsnag-go v1.5.1
go: extracting github.com/bugsnag/bugsnag-go v1.5.1
go: finding github.com/bugsnag/panicwrap v1.2.0
go: downloading github.com/bugsnag/panicwrap v1.2.0
go: finding github.com/gofrs/uuid v3.2.0+incompatible
go: downloading github.com/gofrs/uuid v3.2.0+incompatible
go: extracting github.com/bugsnag/panicwrap v1.2.0
go: extracting github.com/gofrs/uuid v3.2.0+incompatible
go: finding github.com/kardianos/osext latest
go: downloading github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
go: extracting github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
nrxr at lise in ~/code/src/github.com/nrxr/stack
$ cat go.mod
module github.com/nrxr/stack
go 1.12
require (
github.com/bugsnag/bugsnag-go v1.5.1 // indirect
github.com/bugsnag/panicwrap v1.2.0 // indirect
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
)
也许再试一次?尝试一下我刚刚在这里使用的内容。