go get
➜ go get github.com/nats-io/nats-server
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg@version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
go getgo install
➜ go install github.com/nats-io/nats-server
go: finding module for package github.com/nats-io/nats-server
go/pkg/mod/github.com/nats-io/nats-server@v1.4.1/main.go:21:2: cannot find module providing package github.com/nats-io/gnatsd/server
因为当前目录没有 go.mod 文件,所以它需要指定一个版本。
➜ go install github.com/nats-io/nats-server/v2
go: finding module for package github.com/nats-io/nats-server/v2
go install$GOBIN$HOME/go/bin$GOROOT/bin$GOTOOLDIR