From 847764103294b4f61afc50b06bfe19284ac7b7e4 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 25 Mar 2015 17:01:15 +0000 Subject: Remove experimental Go support until we have a solution which fits the 'go' tool conventions better. -- MOS_MIGRATED_REVID=89510837 --- examples/BUILD | 1 - examples/go/BUILD | 22 -------- examples/go/README.md | 121 ------------------------------------------ examples/go/fib.go | 11 ---- examples/go/lib1/BUILD | 29 ---------- examples/go/lib1/fail_test.go | 9 ---- examples/go/lib1/lib1.go | 9 ---- examples/go/lib1/lib1_test.go | 14 ----- 8 files changed, 216 deletions(-) delete mode 100644 examples/go/BUILD delete mode 100644 examples/go/README.md delete mode 100644 examples/go/fib.go delete mode 100644 examples/go/lib1/BUILD delete mode 100644 examples/go/lib1/fail_test.go delete mode 100644 examples/go/lib1/lib1.go delete mode 100644 examples/go/lib1/lib1_test.go (limited to 'examples') diff --git a/examples/BUILD b/examples/BUILD index 5551cb2023..0e42866a36 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -5,7 +5,6 @@ filegroup( srcs = [ "//examples/cpp:srcs", "//examples/gen:srcs", - "//examples/go:srcs", "//examples/java-native:srcs", "//examples/java-skylark:srcs", "//examples/objc:srcs", diff --git a/examples/go/BUILD b/examples/go/BUILD deleted file mode 100644 index 3ade6b5321..0000000000 --- a/examples/go/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -# See README.md for instructions on how to use these rules. - -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/go_rules", "go_library", "go_binary") - -go_binary( - name = "fib", - srcs = glob( - ["*.go"], - exclude = ["*_test.go"], - ), - deps = ["//examples/go/lib1"], -) - -filegroup( - name = "srcs", - srcs = [ - "BUILD", - "//examples/go/lib1:srcs", - ] + glob(["**/*.go"]), -) diff --git a/examples/go/README.md b/examples/go/README.md deleted file mode 100644 index 69bcc4c664..0000000000 --- a/examples/go/README.md +++ /dev/null @@ -1,121 +0,0 @@ - -Go rules --------- - -The files here demonstrate how to use the rules for Go supplied under -`//tools/build_rules:go_rules.bzl`. The rules should be considered -experimental. They support: - - * libraries - * binaries - * tests - -They currently do not support: - - * coverage - * race detector - * multiple target configurations - * //+build tags - * C/C++ interoperation (cgo, swig etc.) - - -Testing -------- - -Setup a symlink to the Go installation you wish to use, - - ln -s /usr/lib/golang/ tools/go/go_root - -or - - ln -s $(go env GOROOT) tools/go/go_root - -To build something, run - - bazel build examples/go/... - -To run a test, run - - bazel test --test_arg=--test.v examples/go/lib1:lib1_test - - -Writing BUILD rules -------------------- - -In the bazel model of compiling Go, each directory can hold multiple -packages, rather than just one in the standard "go" tool. Suppose you -have - - dir/f.go: - - package p - func F() {} - -then in the BUILD file could say - - go_library( - name = "q", - srcs = ["f.go"]) - -and you import it with its Bazel name, - - import "dir/p/q" - -this add the declared package name as namespace, i.e., it is -equivalent to - - import p "dir/p/q" - -so you use it as follows - - import "dir/p/q" - main() { - p.F() - } - - -Writing tests -------------- - -For tests, you should create a separate target, - - go_test( - name = "q_test", - srcs = [ "f_test.go" ], - deps = [ ":q" ]) - -if the test code is in the same package as the library under test -(e.g., because you are testing private parts of the library), you should -use the `library` attribute, - - go_test( - name = "q_test", - srcs = [ "f_test.go" ], - library = ":q" ) - -This causes the test and the library under test to be compiled -together. - - -FAQ ---- - -# Why does this not follow the external Go conventions? - -These rules were inspired on Google's internal Go rules, which work -like this. For Bazel, these make more sense, because directories in -Bazel do not correspond to single targets. - - -# Do I have to specify dependencies twice? - -Yes, once in the BUILD file, once in the source file. Bazel does not -examine file contents, so it cannot infer the dependencies. It is -possible to generate the BUILD file from the Go sources through a -separate program, though. - - -Disclaimer ----------- - -These rules are not supported by Google's Go team. diff --git a/examples/go/fib.go b/examples/go/fib.go deleted file mode 100644 index 43d8a499ba..0000000000 --- a/examples/go/fib.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "fmt" - - "examples/go/lib1/lib1" -) - -func main() { - fmt.Println("Fib(5):", lib1.Fib(5)) -} diff --git a/examples/go/lib1/BUILD b/examples/go/lib1/BUILD deleted file mode 100644 index f65620cbfe..0000000000 --- a/examples/go/lib1/BUILD +++ /dev/null @@ -1,29 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("/tools/build_rules/go_rules", "go_library", "go_binary", "go_test") - -go_library( - name = "lib1", - srcs = glob( - ["*.go"], - exclude = ["*_test.go"], - ), -) - -go_test( - name = "lib1_test", - srcs = [ - "lib1_test.go", - ], - library = ":lib1", -) - -go_test( - name = "fail_test", - srcs = ["fail_test.go"], -) - -filegroup( - name = "srcs", - srcs = ["BUILD"] + glob(["**/*.go"]), -) diff --git a/examples/go/lib1/fail_test.go b/examples/go/lib1/fail_test.go deleted file mode 100644 index 5ef41a3b4d..0000000000 --- a/examples/go/lib1/fail_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package fail - -import ( - "testing" -) - -func TestFail(t *testing.T) { - t.Fatal("I am failing.") -} diff --git a/examples/go/lib1/lib1.go b/examples/go/lib1/lib1.go deleted file mode 100644 index f42494770d..0000000000 --- a/examples/go/lib1/lib1.go +++ /dev/null @@ -1,9 +0,0 @@ -package lib1 - -func Fib(n int) int { - if n < 2 { - return 1 - } - - return Fib(n-1) + Fib(n-2) -} diff --git a/examples/go/lib1/lib1_test.go b/examples/go/lib1/lib1_test.go deleted file mode 100644 index 8eb88a0aca..0000000000 --- a/examples/go/lib1/lib1_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package lib1 - -import ( - "testing" -) - -func TestFib(t *testing.T) { - got := Fib(5) - want := 8 - - if got != want { - t.Fatalf("got %d want %d", got, want) - } -} -- cgit v1.2.3