From 2c27d0f51ddc8193b58aa9c9b89bcb5f97a8b607 Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Thu, 3 Mar 2016 10:32:09 -0800 Subject: [PATCH] Make examples more consistent. Move submodule examples into submodule/* --- BUILD | 23 ++++++----------------- README.md | 6 ++++++ hello.go | 3 +-- local.go | 10 ++++++++++ submodule/BUILD | 21 +++++++++++++++++++++ subbare.go => submodule/bare.go | 2 +- subremote.go => submodule/remote.go | 0 7 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 local.go create mode 100644 submodule/BUILD rename subbare.go => submodule/bare.go (73%) rename subremote.go => submodule/remote.go (100%) diff --git a/BUILD b/BUILD index fe176b4..89a1bd2 100644 --- a/BUILD +++ b/BUILD @@ -4,11 +4,16 @@ package( default_visibility = ["//visibility:public"], ) -go_prefix("github.com/laramiel/bazel-example-golang") +go_prefix("github.com/laramiel/bazel-example-golang/") go_binary( name ="hello", srcs = [ "hello.go" ], +) + +go_binary( + name ="local", + srcs = [ "local.go" ], deps = [ "//local", ], @@ -29,19 +34,3 @@ go_binary( "@bare//:bare", ], ) - -go_binary( - name ="subbare", - srcs = [ "subbare.go" ], - deps = [ - "//submodule/src:bare", - ], -) - -go_binary( - name ="subremote", - srcs = [ "subremote.go" ], - deps = [ - "//submodule/src/remote", - ], -) diff --git a/README.md b/README.md index 4c8a939..4877e5b 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,10 @@ This requires bazel release > `bazel-0.20`. ``` $ bazel run :hello + +$ bazel run :remote +$ bazel run :bare +$ bazel run :subbare +$ bazel run :subremote ``` + diff --git a/hello.go b/hello.go index 1268df7..d390d7c 100644 --- a/hello.go +++ b/hello.go @@ -2,9 +2,8 @@ package main import ( "fmt" - "github.com/laramiel/bazel-example-golang/local/local" ) func main() { - fmt.Println("Hello", local.World()) + fmt.Println("Hello World") } diff --git a/local.go b/local.go new file mode 100644 index 0000000..bf9bf08 --- /dev/null +++ b/local.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "github.com/laramiel/bazel-example-golang/local/local" +) + +func main() { + fmt.Println("Hello ", local.World()) +} diff --git a/submodule/BUILD b/submodule/BUILD new file mode 100644 index 0000000..925552e --- /dev/null +++ b/submodule/BUILD @@ -0,0 +1,21 @@ +load("@bazel_tools//tools/build_rules/go:def.bzl", "go_prefix", "go_binary") + +package( + default_visibility = ["//visibility:public"], +) + +go_binary( + name ="bare", + srcs = [ "bare.go" ], + deps = [ + "//submodule/src:bare", + ], +) + +go_binary( + name ="remote", + srcs = [ "remote.go" ], + deps = [ + "//submodule/src/remote", + ], +) diff --git a/subbare.go b/submodule/bare.go similarity index 73% rename from subbare.go rename to submodule/bare.go index 155f6c4..5b39678 100644 --- a/subbare.go +++ b/submodule/bare.go @@ -6,5 +6,5 @@ import ( ) func main() { - fmt.Println("Hello", local.World()) + fmt.Println("Hello", bare.World()) } diff --git a/subremote.go b/submodule/remote.go similarity index 100% rename from subremote.go rename to submodule/remote.go