diff --git a/example/.aspect/cli/config.yaml b/example/.aspect/cli/config.yaml index 4efdf530..4b251d45 100644 --- a/example/.aspect/cli/config.yaml +++ b/example/.aspect/cli/config.yaml @@ -3,5 +3,6 @@ lint: - //tools:lint.bzl%eslint - //tools:lint.bzl%buf - //tools:lint.bzl%flake8 + - //tools:lint.bzl%golangci_lint - //tools:lint.bzl%pmd - //tools:lint.bzl%ruff diff --git a/example/src/BUILD.bazel b/example/src/BUILD.bazel index 08b0324b..152c4cff 100644 --- a/example/src/BUILD.bazel +++ b/example/src/BUILD.bazel @@ -37,6 +37,7 @@ sh_library( go_binary( name = "hello_go", srcs = ["hello.go"], + deps = ["//src/gopher"], ) cc_binary( diff --git a/example/src/gopher/BUILD.bazel b/example/src/gopher/BUILD.bazel new file mode 100644 index 00000000..a9ba4e0e --- /dev/null +++ b/example/src/gopher/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "gopher", + srcs = ["gopher.go"], + importpath = "gopher", + visibility = ["//visibility:public"], +) diff --git a/example/src/gopher/gopher.go b/example/src/gopher/gopher.go new file mode 100644 index 00000000..dedce7cd --- /dev/null +++ b/example/src/gopher/gopher.go @@ -0,0 +1,5 @@ +package gopher + +func Name() string { + return "Gopher!" +} diff --git a/example/src/hello.go b/example/src/hello.go index f64c44f7..da816a85 100644 --- a/example/src/hello.go +++ b/example/src/hello.go @@ -2,13 +2,22 @@ package main import ( "fmt" + "gopher" + "log" ) -const ( - w = "world" -) +// staticcheck won't like this +var notUsed string func main() { - hello := fmt.Sprintf("Hello %s\n", w) + s := []string{"a"} + // staticcheck also won't like this + if s != nil { + for _, v := range s { + log.Println(v) + } + } + hello := fmt.Sprintf("Hello %s\n", gopher.Name()) fmt.Printf(hello) + _ = s }