Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.09 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.09 KB

FFI Go/Rust

This project implements a simple FFI call of Rust library in Go:

  • The Rust project is compiled as a static library
  • The Go project embeds the Rust library and accesses it with CGO

Pre-requisites

Step 1: Install Golang

  • Install a correctly configured Go toolchain (version 1.17+).
  • Make sure that your GOPATH and GOBIN environment variables are properly set up.

Step 2: Install Rust

Download source code:

# Download sources from github
git clone https://github.com/jpraynaud/ffi-go-rust

# Go to sources directory
cd ffi-go-rust

Build and run binary:

# Build
make build

# Run
make run

# or Build & Run
make

Build and run Docker container:

# Build Docker image
docker build -t ffi-go-rust .

# Run Docker container
docker run --rm --name='ffi-go-rust' ffi-go-rust

Verify

# When running you should see somethingg like this
Hello World in Rust
Addition=110