ebitengine/purego
A library for calling C functions from Go without Cgo
Recommended between 2025-12-13 and 2026-05-08. Last pushed 2026-11-01.
▲ 3 recommend · ▼ 0 criticisms
What hackers say
“It is a bit cursed, but works pretty well.”
— cyberax, 2025-12-13 · strong recommendation · original comment on Hacker News ↗
show original comment
Cgo is terrible, but if you just want some simple C calls from a library, you can use https://github.com/ebitengine/purego to generate the bindings. It is a bit cursed, but works pretty well. I'm using it in my hardware-backed KMIP server to interface with PKCS11.
“You can just embed the C library into the binary of the Go app call it directly in Go.”
— impulser_, 2026-05-08 · original comment on Hacker News ↗
show original comment
Have you tried purego? You can just embed the C library into the binary of the Go app call it directly in Go. Most of the time I have found calling C from Go faster or on par with calling C from Python. https://github.com/ebitengine/purego
“The purego lib generalizes this idea. I haven't got round to trying this yet but it looks very promising.”
— nickcw, 2025-12-13 · original comment on Hacker News ↗
show original comment
That is a nice approach. I'll have to give that a try with rclone. I tried lots of things in the past but not using Alpine which is a great idea Another alternative is https://github.com/ebitengine/purego You can use this to dynamic load shared objects / DLLs so in the OP example they could disable systemd support if the systemd shared object did not load. This technique is used in the cgofuse library ( https://github.com/winfsp/cgofuse ) rclone uses which means rclone can run even if you don't have libfuse/winfsp installed. However the rclone mount subcommand won't work. The purego lib generalizes this idea. I haven't got round to trying this yet but it looks very promising.
Badge for your README
[](https://hackerrepos.org/repo/ebitengine/purego)