You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import (
"go.mongodb.org/mongo-driver/bson""go.mongodb.org/mongo-driver/bson/primitive"
)
type (
Tokenstruct {
Id primitive.ObjectID`bson:"_id,omitempty"`Namestring`bson:"name"`Tokenstring`bson:"token"`UserId primitive.ObjectID`bson:"user_id"`
}
// ...
)
What did you see happen?
On editor (sublime, neovim), because of the unused import "go.mongodb.org/mongo-driver/bson"
it highlights only until the -.
Using gopls command gopls check api/auth/models.go
the output is:
api/auth/models.go:4:2-23: "go.mongodb.org/mongo-driver/bson" imported and not used
23 here is wrong. should be 36.
What did you expect to see?
api/auth/models.go:4:2-36: "go.mongodb.org/mongo-driver/bson" imported and not used
After some research, The issue is in TypeErrorEndPos
tools/gopls/internal/analysisinternal/analysis.go Line 29
if width := bytes.IndexAny(src[offset:], " \n,():;[]+-*"); width > 0 {
after removing the hyphen, it works as expected. I did run the tests after the change but no tests seems to break.
The text was updated successfully, but these errors were encountered:
The inclusion of -+* in TypeErrorEndPos logic was added in https://go.dev/cl/222237; neither the CL description nor any of the test cases reveal why. It would be interesting to instrument go/types to record whenever it produces an error containing one of these symbols, and run its tests (and run it over the standard library) to see what comes up.
adonovan
changed the title
gopls: unused import end is incorrect
gopls: Diagnostics: incorrect end column on errors containing "-" (wrong cutset in TypeErrorEndPos)
Sep 17, 2024
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
adonovan
changed the title
gopls: Diagnostics: incorrect end column on errors containing "-" (wrong cutset in TypeErrorEndPos)
x/tools/gopls: Diagnostics: incorrect end column on errors containing "-" (wrong cutset in TypeErrorEndPos)
Sep 17, 2024
Go version
go1.23.1
Output of
go env
in your module/workspace:What did you do?
Take this example
What did you see happen?
On editor (sublime, neovim), because of the unused import "go.mongodb.org/mongo-driver/bson"
it highlights only until the
-
.Using
gopls
commandgopls check api/auth/models.go
the output is:
api/auth/models.go:4:2-23: "go.mongodb.org/mongo-driver/bson" imported and not used
23 here is wrong. should be 36.
What did you expect to see?
api/auth/models.go:4:2-36: "go.mongodb.org/mongo-driver/bson" imported and not used
After some research, The issue is in
TypeErrorEndPos
tools/gopls/internal/analysisinternal/analysis.go Line 29
if width := bytes.IndexAny(src[offset:], " \n,():;[]+-*"); width > 0 {
after removing the hyphen, it works as expected. I did run the tests after the change but no tests seems to break.
The text was updated successfully, but these errors were encountered: