Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: could not import fmt (no package for import fmt) #40760

Closed
QooGeek opened this issue Aug 13, 2020 · 3 comments
Closed

x/tools/gopls: could not import fmt (no package for import fmt) #40760

QooGeek opened this issue Aug 13, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@QooGeek
Copy link

QooGeek commented Aug 13, 2020

Hi everyone, I just learned golang, this problem has troubled me for a long time, can you help me solve it? thank you very much

go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/alex/Library/Caches/go-build"
GOENV="/Users/alex/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/alex/workspace/learngo"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t2/g3snv2xs0ll_114bqxhz2t6h0000gn/T/go-build374694917=/tmp/go-build -gno-record-gcc-switches -fno-common"

image

gopls -rpc.trace -v check /Users/alex/workspace/test.go

2020/08/14 00:33:25 Info:2020/08/14 00:33:25 Build info
----------
golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/gopls@v0.4.4 h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200729181040-64cdafbe085c h1:jLQLIAedRoS9I2Py7l/ZAGGzUxLFsdg42JXEpS/a+ow=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
    mvdan.cc/gofumpt@v0.0.0-20200709182408-4fd085cb6d5f h1:gi7cb8HTDZ6q8VqsUpkdoFi3vxwHMneQ6+Q5Ap5hjPE=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info
-------
go version go1.14.4 darwin/amd64


2020/08/14 00:33:25 Info:2020/08/14 00:33:25 go env for /Users/alex/workspace/learngo/bin
(root /Users/alex/workspace/learngo/bin)
(valid build configuration = false)
(build flags: [])
GOINSECURE=
GOMOD=
GOPATH=/Users/alex/workspace/learngo
GOPRIVATE=
GOROOT=/usr/local/go
GO111MODULE=
GOCACHE=/Users/alex/Library/Caches/go-build
GOFLAGS=
GOMODCACHE=
GONOPROXY=
GOSUMDB=sum.golang.org
GOPROXY=https://goproxy.cn,direct
GONOSUMDB=

2020/08/14 00:33:25 Info:2020/08/14 00:33:25 go/packages.Load
	snapshot=0
	directory=/Users/alex/workspace/learngo/bin
	query=[./ builtin]
	packages=2
2020/08/14 00:33:25 Info:2020/08/14 00:33:25 go/packages.Load
	snapshot=0
	directory=/Users/alex/workspace/learngo/bin
	query=[./]
	packages=1
@andybons
Copy link
Member

Hi there,

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

Please ask the question on one of the above forums.

(Quoted from https://golang.org/wiki/Questions)

@stamblerre stamblerre changed the title could not import fmt (no package for import fmt)compiler x/tools/gopls: could not import fmt (no package for import fmt)compiler Aug 13, 2020
@stamblerre
Copy link
Contributor

Reopening because this is related to gopls, and I see the problem.

@balainit: It looks like you may not have set up your GOPATH correctly. All of your code needs to be in the /Users/alex/workspace/learngo/src directory. When you run the gopls -rpc.trace -v check /Users/alex/workspace/test.go command, you need to be in the /Users/alex/workspace/ directory.

Alternatively, you can try using Go modules.

@stamblerre stamblerre reopened this Aug 13, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 13, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 13, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.4.5 Aug 13, 2020
@stamblerre stamblerre changed the title x/tools/gopls: could not import fmt (no package for import fmt)compiler x/tools/gopls: could not import fmt (no package for import fmt) compiler Aug 13, 2020
@stamblerre stamblerre changed the title x/tools/gopls: could not import fmt (no package for import fmt) compiler x/tools/gopls: could not import fmt (no package for import fmt) Aug 13, 2020
@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 13, 2020
@stamblerre
Copy link
Contributor

Closing due to a lack of activity.

@golang golang locked and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants