load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") go_library( name = "bin_with_tests_lib", srcs = ["main.go"], _gazelle_imports = [ "example.com/repo/lib", "fmt", ], importpath = "example.com/repo/bin_with_tests", visibility = ["//visibility:private"], ) go_binary( name = "bin_with_tests", _gazelle_imports = [], embed = [":bin_with_tests_lib"], visibility = ["//visibility:public"], ) go_test( name = "bin_with_tests_test", srcs = ["bin_test.go"], _gazelle_imports = ["testing"], embed = [":bin_with_tests_lib"], )