diff --git a/BUILD b/BUILD index 89a1bd2..736307b 100644 --- a/BUILD +++ b/BUILD @@ -7,30 +7,30 @@ package( go_prefix("github.com/laramiel/bazel-example-golang/") go_binary( - name ="hello", - srcs = [ "hello.go" ], + name = "hello", + srcs = ["hello.go"], ) go_binary( - name ="local", - srcs = [ "local.go" ], - deps = [ - "//local", - ], + name = "local", + srcs = ["local.go"], + deps = [ + "//local", + ], ) go_binary( - name ="remote", - srcs = [ "remote.go" ], - deps = [ - "@remote//:remote", - ], + name = "remote", + srcs = ["remote.go"], + deps = [ + "@ws_remote//:remote", + ], ) go_binary( - name ="bare", - srcs = [ "bare.go" ], - deps = [ - "@bare//:bare", - ], + name = "bare", + srcs = ["bare.go"], + deps = [ + "@ws_bare//:bare", + ], ) diff --git a/WORKSPACE b/WORKSPACE index cfe7870..0514ea8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,7 +3,7 @@ load("@bazel_tools//tools/build_rules/go:def.bzl", "go_repositories") go_repositories() git_repository( - name = "remote", + name = "ws_remote", remote = "https://github.com/laramiel/bazel-example-golang-remote.git", commit = "8f2e405", ) @@ -23,7 +23,7 @@ go_library( """ new_git_repository( - name = "bare", + name = "ws_bare", remote = "https://github.com/laramiel/bazel-example-golang-bare.git", commit = "3bd848f", build_file_content = BARE_BUILD diff --git a/bare.go b/bare.go index 5b39678..349d754 100644 --- a/bare.go +++ b/bare.go @@ -1,8 +1,14 @@ -package main +package main import ( "fmt" - "github.com/laramiel/bazel-example-golang-bare/bare" + + // HACK ALERT + // The correct import is this: + // "github.com/laramiel/bazel-example-golang-bare/bare" + // But the bazel build rules for external golang packages like git_repository() are busted. + // We hack around it by importing where those external dependencies end up: + "github.com/laramiel/bazel-example-golang/external/ws_bare/bare" ) func main() { diff --git a/local.go b/local.go index bf9bf08..1eacd5d 100644 --- a/local.go +++ b/local.go @@ -1,4 +1,4 @@ -package main +package main import ( "fmt" diff --git a/remote.go b/remote.go index 0b7c5db..11e39c6 100644 --- a/remote.go +++ b/remote.go @@ -1,8 +1,14 @@ -package main +package main import ( "fmt" - "github.com/laramiel/bazel-example-golang-remote/remote" + + // HACK ALERT + // The correct import is this: + // "github.com/laramiel/bazel-example-golang-remote/remote" + // But the bazel build rules for external golang packages like git_repository() are busted. + // We hack around it by importing where those external dependencies end up: + "github.com/laramiel/bazel-example-golang/external/ws_remote/remote" ) func main() { diff --git a/submodule/bare.go b/submodule/bare.go index 5b39678..48ce4e2 100644 --- a/submodule/bare.go +++ b/submodule/bare.go @@ -1,8 +1,15 @@ -package main +package main import ( "fmt" - "github.com/laramiel/bazel-example-golang-bare/bare" + + // HACK ALERT + // The correct import is this: + // "github.com/laramiel/bazel-example-golang-bare/bare" + // But the bazel build rules for subversion packages don't support alternate + // go_prefix() commands. + // We hack around it by importing where those external dependencies end up: + "github.com/laramiel/bazel-example-golang/submodule/src/bare" ) func main() { diff --git a/submodule/remote.go b/submodule/remote.go index 20230e1..320652e 100644 --- a/submodule/remote.go +++ b/submodule/remote.go @@ -1,8 +1,15 @@ -package main +package main import ( "fmt" - "github.com/laramiel/bazel-example-golang-remote/remote" + + // HACK ALERT + // The correct import is this: + // "github.com/laramiel/bazel-example-golang-bare/bare" + // But the bazel build rules for subversion packages don't support alternate + // go_prefix() commands. + // We hack around it by importing where those external dependencies end up: + "github.com/laramiel/bazel-example-golang/submodule/src/remote/remote" ) func main() {