This post describes an experiment to call Rust code from Go with near-zero overhead, aimed at replacing assembly code for cryptographic operations. It explains why Rust is chosen over assembly and cgo, details the linking process, and provides a working example that integrates Rust and Go. The post concludes with performance benchmarks showing that rustgo is significantly faster than cgo and almost as fast as a Go function call.

26m read timeFrom words.filippo.io
Post cover image
Table of contents
Why RustWhy not cgoLinking it togetherJumping into RustCalling conventionsIs it fast?A real examplePackaging upTurning it into a real thing
1 Comment

Sort: