gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/embeddedbinary/README.md (about)

     1  # embeddedbinary
     2  
     3  `embeddedbinary` can embed a binary inside a Go binary, and provides functions
     4  to execute it.
     5  
     6  Embedded binaries are compressed to save on size. They require temporary disk
     7  space to execute, but the disk space is automatically freed when the child
     8  program exits.
     9  
    10  ## Usage
    11  
    12  Use the `embedded_binary_go_library` rule defined in `defs.bzl`.
    13  
    14  ```build
    15  load(".../defs.bzl", "embedded_binary_go_library")
    16  
    17  # Declare a binary target:
    18  go_binary(
    19      name = "my_binary",
    20      srcs = ["my_binary.go"],
    21  )
    22  
    23  # Generate a go_library rule that can execute the binary target:
    24  embedded_binary_go_library(
    25      name = "my_library",
    26      binary = ":my_binary",
    27  )
    28  ```
    29  
    30  See `test/BUILD` under this directory for a full example.