获取丢失的包 golang.org/x/text/encoding/unicode 导入周期
Get missing package golang.org/x/text/encoding/unicode import cycle
我正在尝试重现 this go issue,但无法轻松构建他们的示例:
$ cat main.go
package main
import ("fmt"; "golang.org/x/text/encoding/unicode")
func main() {
res, err := unicode.UTF16(unicode.BigEndian, unicode.UseBOM).NewDecoder().String(" ")
fmt.Println(res, err)
}
$ go mod init golang.org/x/text/encoding/unicode
go: creating new go.mod: module golang.org/x/text/encoding/unicode
go: to add module requirements and sums:
go mod tidy
$ go mod tidy 1>/dev/null 2>/dev/null
$ go build main.go
package command-line-arguments
imports golang.org/x/text/encoding/unicode
imports golang.org/x/text/encoding/unicode: import cycle not allowed
go mod init golang.org/x/text/encoding/unicode
我怀疑您不应该使用与您的导入同名的模块名称来初始化项目。
尝试:
go mod init test
我正在尝试重现 this go issue,但无法轻松构建他们的示例:
$ cat main.go
package main
import ("fmt"; "golang.org/x/text/encoding/unicode")
func main() {
res, err := unicode.UTF16(unicode.BigEndian, unicode.UseBOM).NewDecoder().String(" ")
fmt.Println(res, err)
}
$ go mod init golang.org/x/text/encoding/unicode
go: creating new go.mod: module golang.org/x/text/encoding/unicode
go: to add module requirements and sums:
go mod tidy
$ go mod tidy 1>/dev/null 2>/dev/null
$ go build main.go
package command-line-arguments
imports golang.org/x/text/encoding/unicode
imports golang.org/x/text/encoding/unicode: import cycle not allowed
go mod init golang.org/x/text/encoding/unicode
我怀疑您不应该使用与您的导入同名的模块名称来初始化项目。
尝试:
go mod init test