我的目标是创建一个包含多个文件夹的存储库。
|- go.work
|- websocket
| |- go.mod
| |- go.sum
| |- server.go
|- channel
| |- main.go
websocket 使用github.com/gorilla/websocket
包。
所以,我需要在websocket
文件夹中做。
$ go mod init github.com/kidfrom/learn-golang/websocket
$ go get github.com/gorilla/websocket@v1.5.0
$ go work use .
问题是,websocket/go.mod
抛出警告
github.com/gorilla/websocket is not used in this module
如果我这样做go mod tidy
,websocket/go.mod
将被清除并websocket/server.go
抛出错误
could not import github.com/gorilla/websocket (no required module provides package "github.com/gorilla/websocket")
TLDR
websocket/go.mod
module github.com/kidfrom/learn-golang/websocket
go 1.19
require github.com/gorilla/websocket v1.5.0 // indirect
websocket/go.sum
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
websocket/server.go
go.work
go 1.19
use (
./websocket
)
噜噜哒
相关分类