Skip to content

go_library: depending on multiple packages with the same import path should be an error #2505

@jayconrod

Description

@jayconrod

What version of rules_go are you using?

v0.23.0

What version of gazelle are you using?

n/a

What version of Bazel are you using?

3.1.0

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

yes

What operating system and processor architecture are you using?

Darwin / amd64

Any other potentially useful information about your toolchain?

n/a

What did you do?

bazel build //:a
-- WORKSPACE --
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "6a68e269802911fa419abb940c850734086869d7fe9bc8e12aaf60a09641c818",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.23.0/rules_go-v0.23.0.tar.gz",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.23.0/rules_go-v0.23.0.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()
-- BUILD.bazel --
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
    name = "a",
    importpath = "a",
    deps = [
        ":b1",
        ":b2",
    ],
)

go_library(
    name = "b1",
    importpath = "b",
    importmap = "b1",
)

go_library(
    name = "b2",
    importpath = "b",
    importmap = "b2",
)

What did you expect to see?

The build should fail because a depends on two targets with importpath = "b". They can't both be imported.

What did you see instead?

Successful compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions