1

What different functionalities do these two declarations make in a Golang project Bazel BUILD file.

example scenario:

go_library(
    name = "go_default_library",
    srcs = [
        "etcd.go",
        "strategy.go",
    ],
    importmap = "path_to_package",
    importpath = "path_to_package",
    deps = [
        "//path_to_dependacy:go_default_library",
        "//path_to_dependacy:go_default_library",
        "//path_to_dependacy:go_default_library",
],
)
martinkaburu
  • 487
  • 6
  • 18

1 Answers1

3

importpath

type: string

default: required value

The source import path of this library. Other libraries can import this library using this path. This must either be specified in go_library or inherited from one of the libraries in embed.


importmap

type: string

default: ""

The actual import path of this library. This is mostly only visible to the compiler and linker, but it may also be seen in stack traces. This may be set to prevent a binary from linking multiple packages with the same import path e.g., from different vendor directories.


Source: Bazel Docs

Nick Corin
  • 2,214
  • 5
  • 25
  • 46
  • What do you think could be the cause for **found forbidden imports for _package_name_**. Bazel Build is failing but the app compiles successfully and the imports work just fine. – martinkaburu Nov 24 '19 at 20:06