go_binary()
This is liable to change in the future.
A go_binary() rule builds a native executable from the supplied set of Go source files and dependencies. The files supplied are expected to be in the main package, implicitly.
Buck currently supports Go version 1.10.
Arguments
name
(required) #The short name for this build target.
srcs
(required) #The set of source files to be compiled by this rule. .go files will be compiled with the Go compiler, .s files will be compiled with the assembler, and everything else is assumed to be files that may be
#include
d by the assembler.deps
(defaults to[]
) #The set of dependencies of this rule. Currently, this only supports go_library rules.
link_style
(defaults tostatic_pic
) #Determines whether to build and link this rule's dependencies statically or dynamically. Can be one of the following values:
static
,static_pic
orshared
. This argument is relevant only if the cgo extension is enabled. Otherwise, Buck ignores this argument.link_mode
(defaults to) #
Determines the link mode (equivalent of
-mode
). Can be one of the following values:internal
,external
. If no value is provided, the mode is set automatically depending on the other args.compiler_flags
(defaults to[]
) #The set of additional compiler flags to pass to
go tool compile
.assembler_flags
(defaults to[]
) #The set of additional assembler flags to pass to
go tool asm
.linker_flags
(defaults to[]
) #Extra linker flags passed to go link
external_linker_flags
(defaults to[]
) #Extra external linker flags passed to go link via
-extld
argument. If argument is non-empty orcgo_library
is used, the link mode will switch toexternal
.resources
(defaults to[]
) #Static files to be symlinked into the working directory of the test. You can access these in your by opening the files as relative paths, e.g.
ioutil.ReadFile("testdata/input")
.visibility
(defaults to[]
) #List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
deps
orexported_deps
attributes. For more information, see visibility.licenses
(defaults to[]
) #Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use
buck query
.labels
(defaults to[]
) #Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query attrfilter()
.
Examples
For more examples, check out our integration tests.
go_binary( name='greet', srcs=[ 'main.go', ], deps=[ ':greeting', ], ) go_library( name='greeting', srcs=[ 'greeting.go', ], deps=[ ':join', ], ) go_library( name='join', srcs=[ 'join.go', ], )