Skip to content

Commit ecacb26

Browse files
committed
chore: demonstrate golangci-lint not working with deps
I get an error like below when I run bazel lint src:hello_go as a result of the go_binary depending on another go target this is a demo of #129 INFO: Analyzed target //src:hello_go (0 packages loaded, 0 targets configured). INFO: From golangcilint src/golangcilint.hello_go.aspect_rules_lint.report: level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"gopher\"" level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"gopher\"\n\n"
1 parent ebe8678 commit ecacb26

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

example/.aspect/cli/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ lint:
33
- //tools:lint.bzl%eslint
44
- //tools:lint.bzl%buf
55
- //tools:lint.bzl%flake8
6+
- //tools:lint.bzl%golangci_lint
67
- //tools:lint.bzl%pmd
78
- //tools:lint.bzl%ruff

example/src/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ sh_library(
3737
go_binary(
3838
name = "hello_go",
3939
srcs = ["hello.go"],
40+
deps = ["//src/gopher"],
4041
)
4142

4243
cc_binary(

example/src/gopher/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "gopher",
5+
srcs = ["gopher.go"],
6+
importpath = "gopher",
7+
visibility = ["//visibility:public"],
8+
)

example/src/gopher/gopher.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package gopher
2+
3+
func Name() string {
4+
return "Gopher!"
5+
}

example/src/hello.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@ package main
22

33
import (
44
"fmt"
5+
"gopher"
6+
"log"
57
)
68

7-
const (
8-
w = "world"
9-
)
9+
// staticcheck won't like this
10+
var notUsed string
1011

1112
func main() {
12-
hello := fmt.Sprintf("Hello %s\n", w)
13+
s := []string{"a"}
14+
// staticcheck also won't like this
15+
if s != nil {
16+
for _, v := range s {
17+
log.Println(v)
18+
}
19+
}
20+
hello := fmt.Sprintf("Hello %s\n", gopher.Name())
1321
fmt.Printf(hello)
22+
_ = s
1423
}

0 commit comments

Comments
 (0)