使用 Go Get 安装后无法导入包?

The package could not be imported after you installed it using Go Get ?

我开启了GO111MODULE=on,在使用Go Get -u安装包时,会安装到PGK目录下,但安装后无法使用

Go版本go1.15.6Windows/amd64

go.mod 文件

module github.com/xanzy/go-gitlab

go 1.15

去环境

E:\code\awesomeProject2\src>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\Go\bin
set GOCACHE=C:\Users\code\AppData\Local\go-build
set GOENV=C:\Users\code\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=E:\code\awesomeProject2\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\code\awesomeProject2
set GOPRIVATE=
set GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
set GOROOT=D:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\code\awesomeProject2\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\guji\AppData\Loc
al\Temp\go-build895842770=/tmp/go-build -gno-record-gcc-switches

go build gitlab_merge_requests.go 我得到了错误

package github.com/xanzy/go-gitlab
imports github.com/xanzy/go-gitlab: import cycle not allowed

这是我的代码

package main

import (
"log"
"net/http"
"net/http/httptest"
"github.com/xanzy/go-gitlab"
)



var (
Token = "XXXXXX" // token information
url = "https://xxxxx" // gitlab URL
)

func setup() (*http.ServeMux, *httptest.Server, *gitlab.Client) {

// mux is the HTTP request multiplexer used with the test server.

mux := http.NewServeMux()



// server is a test HTTP server used to provide mock API responses.

server := httptest.NewServer(mux)



// client is the Gitlab client being tested.

client := gitlab.NewClient(nil, token)
client.SetBaseURL(url)


return mux, server, client

}



func main(){
_, _, client := setup()


users, _, err := client.Users.ListUsers(&gitlab.ListUsersOptions{})
if err ! = nil {

panic(err)

}

for _, user := range users {
log.Println(user.Username, user.Name, user.CreatedAt.Format("2006-01-02"))

}
}

刚学Golang,谁能帮帮我?

import cycle not allowed 告诉我你有导入的循环引用。 A导入B又导入A,甚至A导入A。

你的 go.mod 文件说 你的模块 被命名为 github.com/xanzy/go-gitlab。当您尝试导入该路径时,Go 认为您的包正在尝试导入 自身 ,这是不可能的,并引发错误。

删除你的go.mod并用你自己的模块路径重新运行go mod init(如果你有一个repo,如果你永远不打算与任何人分享它,你可以使用任何你喜欢的东西)。然后你就可以go get正确