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: make it clearer when diagnostics come from a non-default build context #65496

Closed
pjweinb opened this issue Feb 3, 2024 · 5 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@pjweinb
Copy link

pjweinb commented Feb 3, 2024

Go version

go1.21.6

Output of go env in your module/workspace:

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/pjw/Library/Caches/go-build"
GOENV="/Users/pjw/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/pjw/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pjw/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/pjw/alt/telemetry/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xx/sy8s7hy16mnfcj8kyn5hwq5800052r/T/go-build2649792271=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

download x/telemetry at tip. Then in counter/counter.go and counter/counter_disabled.go remove the references to 386 in //go:build lines. (one in each file)

What did you see happen?

Type errors on c in counter/countertest/counter_test.go:

cannot use c (variable of type *"golang.org/x/telemetry/counter".Counter) as *"golang.org/x/telemetry/internal/counter".Counter value in argument to ReadCountercompilerIncompatibleAssign

What did you expect to see?

no errors. The tests in countertest/counter_test.go compile without errors and run.

@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 Feb 3, 2024
@gopherbot gopherbot added this to the Unreleased milestone Feb 3, 2024
@findleyr
Copy link
Contributor

findleyr commented Feb 4, 2024

The errors are because you have counter_disabled.go open, and gopls automatically creates a View to cover the counter_disabled file. The countertest package does have errors when compiled with counter_disabled.go -- exactly the errors reported.

We should make it clearer when the errors are not from the default view of a file.

@findleyr
Copy link
Contributor

findleyr commented Feb 4, 2024

To be clear: the change to 386 is irrelevant. You will see these errors as soon as you open counter_disabled.go, without any changes to the repository.

@findleyr findleyr changed the title x/tools/gopls: incorrect errors associated with build tags x/tools/gopls: make it clearer when diagnostics come from a non-default build context Feb 4, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.15.0 Feb 4, 2024
@pjweinb
Copy link
Author

pjweinb commented Feb 4, 2024 via email

@adonovan adonovan self-assigned this Feb 13, 2024
@gopherbot
Copy link

Change https://go.dev/cl/563876 mentions this issue: gopls/internal/server: give OS/ARCH suffix to diagnostics

@gopherbot
Copy link

Change https://go.dev/cl/564557 mentions this issue: [gopls-release-branch.0.15] gopls/internal/server: disambiguate diagnostics by OS,ARCH

gopherbot pushed a commit to golang/tools that referenced this issue Feb 16, 2024
…ostics by OS,ARCH

This change adds a disambiguating suffix such as " [windows,arm64]"
to diagnostics that do not appear in the default build configuration.

Fixes golang/go#65496

Change-Id: Ided7a7110ff630e57b7a96a311a240fef210ca93
Reviewed-on: https://go-review.googlesource.com/c/tools/+/563876
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit df9c1c7)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564557
Reviewed-by: Alan Donovan <adonovan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants