Skip to content

jpraynaud/ffi-go-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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