build a demo to test the Bazel build golang project, located at D:\ workspace\ www\ go_work\ src\ golang_learning
, with the following file:
golang_learning
|__ go.mod
|__ main.go
|__ WORKSPACE
|__ BUILD.bazel
the contents of each file are as follows: WORKSPACE
and BUILD.bazel
of Bazel https://github.com/bazelbuild.go.mod
module golang_learning
main.go
package main
import "fmt"
func main() {
fmt.Println("Hello,world")
}
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.16.1/rules_go-0.16.1.tar.gz"],
sha256 = "f5127a8f911468cd0b2d7a141f17253db81177523e4429796e14d429f5444f5f",
)
http_archive(
name = "bazel_gazelle",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.15.0/bazel-gazelle-0.15.0.tar.gz"],
sha256 = "6e875ab4b6bf64a38c352887760f21203ab054676d9c1b274963907e0768740d",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
BUILD.bazel
load("@bazel_gazelle//:def.bzl", "gazelle")
-sharp gazelle:prefix github.com/example/project
gazelle(name = "gazelle")
when running bazel run / /: gazelle
, the following error occurs:
PS D:\workspace\www\go_work\src\golang_learning> bazel run //:gazelle
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: "BAZEL_VC" is not set, start looking for the latest Visual CPP installed.
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for Visual CPP through registry
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for default Visual CPP installation directory
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: "PROGRAMFILES(X86)" environment variable is not set, using "C:\Program Files (x86)" as default
ERROR: Analysis of target "//:gazelle" failed; build aborted: no such package "@org_golang_x_tools//go/gcexportdata": java.io.IOException: thread interrupted
INFO: Elapsed time: 339.763s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (42 packages loaded)
FAILED: Build did NOT complete successfully (42 packages loaded)
what is not configured correctly?