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/cmd/gopls: no packages found for ad-hoc package #32487

Closed
raxod502 opened this issue Jun 7, 2019 · 3 comments
Closed

x/tools/cmd/gopls: no packages found for ad-hoc package #32487

raxod502 opened this issue Jun 7, 2019 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@raxod502
Copy link

raxod502 commented Jun 7, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.5 darwin/amd64

Does this issue reproduce with the latest release?

I'm using 1.12.5 which is the latest release according to this page. I just ran go get -u golang.org/x/tools/cmd/gopls so presumably gopls is up to date.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/raxod502/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/raxod502/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/raxod502/code/goval/go.mod"
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/f6/sdzsx0rn71g8_5xxqg3bm9fw0000gn/T/go-build670253121=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Put in file main.go in an otherwise empty directory:

package main

import "fmt"

func main() {
	fmt.Println("Hello World")
}

Then run:

% gopls check main.go

What did you expect to see?

Some diagnostics, maybe. Not an error. (I don't actually use this command specifically; I narrowed down the error from an LSP failure in Emacs.)

What did you see instead?

2019/06/07 14:24:10 Error:unable to check package for file:///Users/raxod502/temp/go-test/main.go: no packages found for /Users/raxod502/temp/go-test/main.go
2019/06/07 14:24:10 Error:unable to check package for file:///Users/raxod502/temp/go-test/main.go: no packages found for /Users/raxod502/temp/go-test/main.go
2019/06/07 14:24:10 Error:failed to deliver diagnostic for file:///Users/raxod502/temp/go-test/no%20packages%20found%20for%20/Users/raxod502/temp/go-test/main.go: stat /Users/raxod502/temp/go-test/no packages found for /Users/raxod502/temp/go-test/main.go: no such file or directory
@gopherbot gopherbot added this to the Unreleased milestone Jun 7, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 7, 2019
@muirdm
Copy link

muirdm commented Jun 8, 2019

In module mode you need a go.mod file for gopls to load the package properly. I think there are plans to improve the messaging to make this more clear.

@wubo0067
Copy link

I had the same problem.

@stamblerre
Copy link
Contributor

This issue is now fixed on master, as of golang/tools@1d40570.

@stamblerre stamblerre changed the title x/tools/cmd/gopls: no packages found x/tools/cmd/gopls: no packages found for ad-hoc package Jun 18, 2019
@golang golang locked and limited conversation to collaborators Jun 17, 2020
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.
Projects
None yet
Development

No branches or pull requests

5 participants