我有一个可执行的 go 模块,我正在尝试执行以下命令
go get github.com/saipraveen-a/number-manipulation/v2
并得到这个错误:
module github.com/saipraveen-a/number-manipulation@upgrade found (v1.0.1), but does not contain package github.com/saipraveen-a/number-manipulation/v2
number-manipulation是一个不可执行的 go 模块,带有以下标签 v1.0.0、v1.0.1 和 v2.0.0。
我是新来的。所以有人请告诉我这里有什么问题。
带主包的模块
应用程序.go
package main
import (
"fmt"
"github.com/saipraveen-a/number-manipulation/calc"
calcNew "github.com/saipraveen-a/number-manipulation/v2/calc"
)
func main() {
result := calc.Add(1, 2)
fmt.Println("calc.Add(1,2) =>", result)
result = calc.Add(1, 2, 3, 4, 5)
fmt.Println("calc.Add(1,2,3,4,5) =>", result)
newResult, err = calcNew.Add()
if err != nil {
fmt.Println("Error: =>", error)
} else {
fmt.Println("calcNew.Add(1,2,3,4) =>", calcNew.Add(1, 2, 3, 4))
}
}
去.mod
module main
go 1.14
require github.com/saipraveen-a/number-manipulation v1.0.1
go 版本 go1.14.3 darwin/amd64
去环境
GO111MODULE=""
GOPATH="/Users/<user-id>/Golang"
GOMOD="/Users/<user-id>/GoModules/main/go.mod"
我试过 set GO111MODULE=on; 但这不会改变 GO111MODULE 的值
# go build app.go
go: finding module for package github.com/saipraveen-a/number-manipulation/v2/calc
app.go:7:2: module github.com/saipraveen-a/number-manipulation@latest found (v1.0.1), but does not contain package github.com/saipraveen-a/number-manipulation/v2/calc