xref: /aosp_15_r20/external/bazelbuild-rules_go/tests/core/go_binary/README.rst (revision 9bb1b549b6a84214c53be0924760be030e66b93a)
1Basic go_binary functionality
2=============================
3
4.. _go_binary: /docs/go/core/rules.md#_go_binary
5.. _#2168: https://github.com/bazelbuild/rules_go/issues/2168
6.. _#2463: https://github.com/bazelbuild/rules_go/issues/2463
7
8Tests to ensure the basic features of go_binary are working as expected.
9
10hello
11-----
12
13Hello is a basic "hello world" program that doesn't do anything interesting.
14Useful as a primitive smoke test -- if this doesn't build, nothing will.
15
16out_test
17--------
18
19Tests that a `go_binary`_ rule can write its executable file with a custom name
20in the package directory (not the mode directory).
21
22package_conflict_test
23---------------------
24
25Tests that linking multiple packages with the same path (`importmap`) is an
26error.
27
28goos_pure_bin
29-------------
30
31Tests that specifying the `goos` attribute on a `go_binary`_ target to be
32different than the host os forces the pure mode to be on. This is achieved
33by including a broken cgo file in the sources for the build.
34
35many_deps
36---------
37
38Test that a `go_binary`_ with many imports with long names can be linked. This
39makes sure we don't exceed command-line length limits with -I and -L flags.
40Verifies #1637.
41
42stamp_test
43----------
44Test that the `go_binary`_ ``x_defs`` attribute works correctly, both in a
45binary and in an embedded library. Tests regular stamps and stamps that
46depend on values from the workspace status script. Verifies #2000.
47
48pie_test
49--------
50Tests that specifying the ``linkmode`` attribute on a `go_binary`_ target to be
51pie produces a position-independent executable and that no specifying it produces
52a position-dependent binary.
53
54static_test
55-----------
56Test that `go_binary`_ rules with ``static = "on"`` with and without cgo
57produce static binaries. Verifies `#2168`_.
58
59This test only runs on Linux. The darwin external linker cannot produce
60static binaries since there is no static version of C runtime libraries.
61
62tags_bin
63--------
64Checks that setting ``gotags`` affects source filtering. This binary won't build
65without a specific tag being set.
66
67prefix
68------
69This binary has a name that conflicts with a subdirectory. Its output file
70name should not have this conflict. Verifies `#2463`_.
71