https://github.com/ryanfowler/cgo-rs
A library to compile Go into a Rust library or application
https://github.com/ryanfowler/cgo-rs
build cargo cgo cgo-rust go golang rust
Last synced: 24 days ago
JSON representation
A library to compile Go into a Rust library or application
- Host: GitHub
- URL: https://github.com/ryanfowler/cgo-rs
- Owner: ryanfowler
- License: mit
- Created: 2023-06-05T15:46:12.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-08-07T13:41:41.000Z (9 months ago)
- Last Synced: 2025-12-14T02:29:45.472Z (5 months ago)
- Topics: build, cargo, cgo, cgo-rust, go, golang, rust
- Language: Rust
- Homepage:
- Size: 26.4 KB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cgo-rs
[](https://crates.io/crates/cgo)
A library for build scripts to compile custom Go code, inspired by the
excellent [cc](https://docs.rs/cc/latest/cc) crate.
It is intended that you use this library from within your `build.rs` file by
adding the cgo crate to your [`build-dependencies`](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#build-dependencies):
```toml
[build-dependencies]
cgo = "*"
```
# Examples
The following example will statically compile the Go package and instruct
cargo to link the resulting library (`libexample`).
```rust
fn main() {
cgo::Build::new()
.package("pkg/example/main.go")
.build("example");
}
```