Skip to content

x_defs not taking effect when used as described in readme #2000

@codesuki

Description

@codesuki

What version of rules_go are you using?

0.18.1

What version of gazelle are you using?

0.17.0

What version of Bazel are you using?

Build label: 0.23.2-homebrew

Does this issue reproduce with the latest releases of all the above?

yes

What operating system and processor architecture are you using?

osx

Any other potentially useful information about your toolchain?

What did you do?

cmd/server/main.go

package main
import "fmt"
var version string
var serviceName string

func main() {
	fmt.Println(version, serviceName)
}

cmd/server/BUILD.bazel

go_library(
    name = "go_default_library",
    srcs = ["main.go"],
    importpath = "github.com/xxx/cmd/server",
    visibility = ["//visibility:private"],
    x_defs = {
        "version": "{STABLE_GIT_COMMIT}",
        "main.serviceName": "{SERVICE_NAME}",
    },
    deps = [
    ],
)

What did you expect to see?

HEAD serviceName

What did you see instead?

serviceName

When I remove main. from "main.serviceName": "{SERVICE_NAME}", I get no output.
When I add main. to the version, the version shows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions