forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide an example for the Go rules, eg.
bazel test examples/go/lib:lib_test bazel build examples/go/bin:bin -- MOS_MIGRATED_REVID=105070940
- Loading branch information
Showing
9 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
load("/tools/build_rules/go/def", "go_binary") | ||
|
||
go_binary( | ||
name = "bin", | ||
srcs = ["bin.go"], | ||
deps = [ | ||
"//examples/go/lib:go_default_library", | ||
"//examples/go/vendor/github_com/user/vendored:go_default_library", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github_com/user/vendored" | ||
|
||
"github.com/bazelbuild/bazel/examples/go/lib" | ||
) | ||
|
||
func main() { | ||
fmt.Println("meaning: ", lib.Meaning()) | ||
fmt.Println("vendored: ", vendored.Vendored()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
load("/tools/build_rules/go/def", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"lib.go", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "lib_test", | ||
srcs = [ | ||
"lib_test.go", | ||
], | ||
library = ":go_default_library", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package lib | ||
|
||
// Meaning calculates the meaning of Life, the Universe and Everything. | ||
func Meaning() int { | ||
return 42 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package lib | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMeaning(t *testing.T) { | ||
if m := Meaning(); m != 42 { | ||
t.Errorf("got %d, want 42", m) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
load("/tools/build_rules/go/def", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"vendored.go", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package vendored | ||
|
||
// Vendored returns a string. | ||
func Vendored() string { | ||
return "I was vendored" | ||
} |