Hi all. I'm attempting to create a new Go project and initialized my repo with a rules_go
and gazelle
. When attempting to verify that all works by running bazel run gazelle
I get the following output:
$ bazel run :gazelle
INFO: Analysed target //:gazelle (0 packages loaded).
INFO: Found 1 target...
Target //:gazelle up-to-date:
bazel-bin/gazelle.bash
INFO: Elapsed time: 0.589s, Critical Path: 0.00s
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/gazelle.bash
Loading:
Loading: 0 packages loaded
ERROR: Skipping '//:gazelle': no such package '': BUILD file not found on package path
WARNING: Target pattern parsing failed.
ERROR: no such package '': BUILD file not found on package path
INFO: Elapsed time: 0.029s
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
error: /home/sadpengu/.cache/bazel/_bazel_sadpengu/ec883637456c7798d953715093f767e5/execroot/com_zenreach_hydroponics/bazel-out/k8-fastbuild/bin/gazelle.bash: script is out of date. Refresh it with the command:
bazel build //:gazelle && cp -fv "" "/home/sadpengu/.cache/bazel/_bazel_sadpengu/ec883637456c7798d953715093f767e5/execroot/com_zenreach_hydroponics/bazel-out/k8-fastbuild/bin/gazelle.bash"
ERROR: Non-zero return code '1' from command: Process exited with status 1
workspace(
name = "redacted",
)
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/releases/download/0.8.1/rules_go-0.8.1.tar.gz",
sha256 = "90bb270d0a92ed5c83558b2797346917c46547f6f7103e648941ecdb6b9d0e72",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
http_archive(
name = "bazel_gazelle",
url = "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.8/bazel-gazelle-0.8.tar.gz",
sha256 = "e3dadf036c769d1f40603b86ae1f0f90d11837116022d9b06e4cd88cae786676",
)
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
load("@bazel_gazelle//:def.bzl", "gazelle")
gazelle(
name = "gazelle",
prefix = "github.com/zenreach/redacted",
)
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
$ bazel version
Build label: 0.9.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Mar 21 00:11:16 +49984 (1515182371876)
Build timestamp: 1515182371876
Build timestamp as int: 1515182371876
$ ./bazel-bin/gazelle.bash
Loading:
Loading: 0 packages loaded
INFO: Analysed target //:gazelle (0 packages loaded).
INFO: Found 1 target...
[0 / 1] [-----] BazelWorkspaceStatusAction stable-status.txt
Target //:gazelle up-to-date:
bazel-bin/gazelle.bash
INFO: Elapsed time: 0.626s, Critical Path: 0.00s
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Loading:
Loading: 0 packages loaded
INFO: Analysed target @bazel_gazelle//cmd/gazelle:gazelle (0 packages loaded).
INFO: Found 1 target...
[0 / 4] [-----] BazelWorkspaceStatusAction stable-status.txt
Target @bazel_gazelle//cmd/gazelle:gazelle up-to-date:
bazel-bin/external/bazel_gazelle/cmd/gazelle/linux_amd64_stripped/gazelle
INFO: Elapsed time: 0.635s, Critical Path: 0.01s
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
$ cat src/BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/zenreach/redacted/src",
visibility = ["//visibility:private"],
)
go_binary(
name = "src",
embed = [":go_default_library"],
importpath = "github.com/zenreach/redacted/src",
visibility = ["//visibility:public"],
)