Buck: go_library()

go_library()

This is liable to change in the future.

A go_library() rule builds a native library from the supplied set of Go source files and dependencies.

Note: Buck is currently tested with (and therefore supports) version 1.5 of Go.

Arguments

  • name (required) #

    The name of the rule.

  • 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 #included by the assembler.

  • package_name (defaults to go.prefix + path relative to the buck root) #

    Sets the full name of the package being compiled. This defaults to the path from the buck root. (e.g. given a ./.buckconfig, a rule in ./a/b/BUCK defaults to package "a/b")

  • deps (defaults to []) #

    The set of dependencies of this rule. Currently, this only supports go_library rules.

  • cgo_deps (defaults to []) #

    The set of cgo_library dependencies which gets compiled and linked as cgo extension.

  • 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.

  • tests (defaults to []) #

    List of build targets that identify the test rules that exercise this target.

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule in its deps.

  • 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_library(
  name='greeting',
  srcs=[
    'greeting.go',
  ],
  deps=[
    ':join',
  ],
)