Bazel go binary

From NovaOrdis Knowledge Base
Revision as of 03:40, 23 July 2024 by Ovidiu (talk | contribs) (Created page with "=Overview= =Example= <syntaxhighlight lang='go'> load("//meta/rules:go.bzl", "go_library", "go_binary") go_library( name = "somepkg_lib", srcs = [ "file1.go", "file2.go", ], importpath = "github.com/someorg/somemodule/pkg/somepkg", visibility = ["//visibility:private"], deps = [ "//lib/a", "//lib/b", ... "@com_github_blang_semver//:semver", ], ) go_binary( name = "somebin", embed = [":s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Example

load("//meta/rules:go.bzl", "go_library", "go_binary")

go_library(
    name = "somepkg_lib",
    srcs = [
        "file1.go",
        "file2.go",
    ],
    importpath = "github.com/someorg/somemodule/pkg/somepkg",
    visibility = ["//visibility:private"],
    deps = [
        "//lib/a",
        "//lib/b",
        ...
        "@com_github_blang_semver//:semver",
    ],
)

go_binary(
    name = "somebin",
    embed = [":somepkg_lib"],
    visibility = ["//visibility:public"],
    x_defs = {"github.com/someorg/somemodule/version.Version": "{BUILD_VERSION}"},
)