Skip to content

go_library

Go package compiled into an archive.

The target accepts every common Go attribute, including source embedding, build constraints, cgo, cross-compilation, sanitizers, coverage, and compiler options. It additionally accepts x_defs as a map of Bazel-compatible link-time string definitions retained for embedded binary migrations.

Dependency Edges

EdgeAcceptsDescription
depsgo_package, go_dependency_set, c_providerGo packages, locked modules, and native providers
embedgo_packageSources compiled into the same package
cdepsc_providerNative dependencies consumed through cgo

Providers, Capabilities, and Outputs

The target emits go_package. build exposes the library output group and writes .once/out/<target>/lib<target>.a, or the destination platform archive extension.

Example

toml
[[target]]
name = "Greeting"
kind = "go_library"
srcs = ["internal/greeting/*.go"]
deps = ["GoDependencies"]

[target.attrs]
package = "./internal/greeting"
importpath = "example.com/hello/internal/greeting"

Released under an open-source license.