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

gopackagesdriver doesn't work with golangci-lint #3523

Closed
grampelberg opened this issue Apr 6, 2023 · 3 comments · Fixed by #3524 or #3552
Closed

gopackagesdriver doesn't work with golangci-lint #3523

grampelberg opened this issue Apr 6, 2023 · 3 comments · Fixed by #3524 or #3552

Comments

@grampelberg
Copy link
Contributor

What version of rules_go are you using?

v0.39.0

What version of gazelle are you using?

v0.30.0

What version of Bazel are you using?

6.1.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

linux-amd64

Any other potentially useful information about your toolchain?

What did you do?

Exported GOPACKAGESDRIVER and GOPACKAGESDRIVER_BAZEL_QUERY_SCOPE, ran golangci-lint.

What did you expect to see?

A successful run of golangci-lint with no typecheck errors.

What did you see instead?

Silent failures because golangci-lint wasn't able to load the types from source and gave up on non-local libraries.

@grampelberg
Copy link
Contributor Author

There are a couple issues here:

  • golangci-lint supports go list query syntax which is less explicit that the current file= support required by gopls.
  • Because imports are resolved by path in gopackagesdriver, if you have the same import path for multiple IDs it is possible for the wrong source to be referenced.
  • stdlib does not include any generated files, namely the CGO files for packages such as net.
  • WKT for protobufs are skipped because they use a library attribute instead of the current ones.

@grampelberg
Copy link
Contributor Author

grampelberg commented Apr 6, 2023

I've got this working now in my branch.

grampelberg pushed a commit to grampelberg/rules_go that referenced this issue Apr 7, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- stdlib now includes CGO processed files.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue Apr 7, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- stdlib now includes CGO processed files.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue Apr 25, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- stdlib now includes CGO processed files.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 2, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 2, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`

Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 8, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`

Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 8, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 9, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 9, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 10, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662
linzhp pushed a commit that referenced this issue May 10, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes #3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662

Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
grampelberg pushed a commit to grampelberg/rules_go that referenced this issue May 16, 2023
…d#3523)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`

Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e
linzhp pushed a commit that referenced this issue May 24, 2023
…3524)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`

Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e

Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
tingilee pushed a commit to tingilee/rules_go that referenced this issue Jul 19, 2023
The stdlib json currently is not populated with generated files. When
CGO is being used, this means that the file list returned does not
actually compile. This change adds `-compiled=true` to go list's output
which results in the full set required to compile stdlib.

Fixes bazelbuild#3523

Change-Id: Ic06243e7a5de68946d87ff9734156c522bfd8662

Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
tingilee pushed a commit to tingilee/rules_go that referenced this issue Jul 19, 2023
…d#3523) (bazelbuild#3524)

Unlike gopls which uses `file=` queries exclusively, golangci-lint uses
the more generic `go list` query syntax. This change allow for file
paths not prefixed with `file=` to be queried correctly.

Additionally, some bugs have been fixed up:
- Packages with different IDs and identical import paths work now.
- WKT for protobufs are no longer skipped when the proto wrapper is
  used.`

Change-Id: Ie1fc571f52cf5f6d1ff94b0aea2c05c06bb4be4e

Co-authored-by: Thomas Rampelberg <thomas.rampelberg@airbnb.com>
@dbernadett
Copy link

@grampelberg I am trying to get golangci-lint working with bazel. Could you help me get on the right path? I have some example code here:
https://github.com/dbernadett/golanglint-x-bazel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants