rust-plus-golang

Rust + Go

Github星跟蹤圖

Rust + Golang


This repository shows how, by combining
cgo and
Rust's FFI capabilities, we can call
Rust code from Golang.

Run make build and then ./main to see Rust + Golang in action. You
should see Hello John Smith! printed to stdout.

You can do this for your own project

Begin by creating a lib directory, where you will keep your Rust libraries.
Andrew Oppenlander's article on creating a Rust dynamic library is a great introduction.

Then, you need to create a C header file for your library. Just copy the libc
types that you used.

All that is left to do is to add some cgo-specific comments to your Golang
code. These comments tell cgo where to find the library and its headers.

/*
#cgo LDFLAGS: -L./lib -lhello
#include "./lib/hello.h"
*/
import "C"

There should not be a newline between */ and import "C".

A simple make build (use the Makefile in this repository) will
result in a binary that loads your dynamic library.

主要指標

概覽
名稱與所有者mediremi/rust-plus-golang
主編程語言Makefile
編程語言Makefile (語言數: 4)
平台
許可證MIT License
所有者活动
創建於2015-05-09 10:57:59
推送於2024-10-24 02:34:31
最后一次提交2024-10-24 11:34:28
發布數0
用户参与
星數772
關注者數6
派生數60
提交數12
已啟用問題?
問題數0
打開的問題數0
拉請求數3
打開的拉請求數1
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?