https://github.com/danielmorell/go-rust-embed
Embed a Rust Binary In a Go Program
https://github.com/danielmorell/go-rust-embed
Last synced: about 1 month ago
JSON representation
Embed a Rust Binary In a Go Program
- Host: GitHub
- URL: https://github.com/danielmorell/go-rust-embed
- Owner: danielmorell
- Created: 2022-04-05T17:57:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-05T17:59:05.000Z (over 4 years ago)
- Last Synced: 2025-01-05T00:44:09.562Z (over 1 year ago)
- Language: Go
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Embed a Rust Binary In a Go Program
This is a really simple proof of concept that embeds a Rust binary in a Go program. The
Rust binary can be executed from the Go program, and is also shipped as part of the Go
binary.
You can run this little example as follows...
```
$ go generate . && go run .
```
And build it like so...
```
$ go generate . && go build .
```
The `go generate .` part will discover the `//go:generate` comment in
[main.go:9](main.go#9) and execute the rest of the line as a shell command.
On [main.go:10](main.go#10) we use `//go:embed` to include the compiled rust binary into
the Go program when it is compiled.