Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

fastcgo

> 编程语言
Open source

fastcgo Fast (but unsafe) Cgo calls via an assembly trampoline. Inspired by rustgo. The UnsafeCall function takes a pointer to a Cgo functi…

197 stars0 likes0 views
WebsiteGitHub

About

fastcgo Fast (but unsafe) Cgo calls via an assembly trampoline. Inspired by rustgo. The UnsafeCall function takes a pointer to a Cgo functi…

fastcgo

Fast (but unsafe) Cgo calls via an assembly trampoline. Inspired by rustgo. The UnsafeCall* function takes a pointer to a Cgo function and a number of arguments and executes the function on the "system stack" of the thread the current Goroutine is running on. Usage looks like:

package hello

// #include 
// #include 
// void hello(uint64_t arg) {
//   printf("Hello, C: %lld\n", arg)
// }
import "C"

import (
	"github.com/petermattis/fastcgo"
)

func Hello(arg uint64) {
	fastcgo.UnsafeCall4(C.hello, arg, 0, 0, 0)
}

The upshot is significantly faster transitions into C/C++:

~/go/src/github.com/petermattis/fastcgo master go test -run=- -bench=. ./bench/
...
BenchmarkGO-8        	2000000000	         1.90 ns/op
BenchmarkCGO-8       	30000000	        60.1  ns/op
BenchmarkFastCGO-8   	300000000	         4.63 ns/op
...

WARNING: No attempt is made to play nice with the Go scheduler or GC. The goroutine executing a fastcgo call will never be interrupted and will delay the starting or completion of GC until it finishes.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Go

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言