Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. purego

purego

Apache-2.0Assemblyv0.10.1

A Go library for calling C functions and loading shared libraries without Cgo, enabling cross-compilation and smaller binaries.

GitHubGitHub
3.7k stars109 forks0 contributors

What is purego?

Purego is a Go library that provides a foreign function interface (FFI) to call C functions and load shared libraries without requiring Cgo. It enables Go developers to interact with C libraries and system APIs while maintaining the benefits of pure Go compilation, such as cross-compilation support and reduced binary size.

Target Audience

Go developers who need to call C libraries or system APIs but want to avoid the complexities and limitations of Cgo, particularly those working on cross-platform projects or requiring dynamic linking capabilities.

Value Proposition

Developers choose Purego over Cgo because it eliminates C dependencies, enabling simpler cross-compilation, faster builds, smaller binaries, and dynamic runtime loading of shared objects, all while offering a fallback to Cgo for incremental porting and unsupported architectures.

Overview

A library for calling C functions from Go without Cgo

Use Cases

Best For

  • Cross-compiling Go applications to multiple platforms (like Windows, Linux, macOS, Android, iOS) without needing a C compiler for the target.
  • Reducing binary size and improving build times by avoiding Cgo-generated wrapper functions.
  • Dynamically loading symbols at runtime from shared objects (.so, .dylib, .dll) for plugin-like functionality.
  • Calling C functions or system APIs in environments where Cgo is restricted or unavailable.
  • Incrementally porting existing Cgo-dependent Go code to a Cgo-free implementation with fallback support.
  • Interfacing with foreign language libraries compiled into shared objects from Go.

Not Ideal For

  • Projects requiring seamless support for all Go architectures without special build flags or CGO fallbacks
  • Teams that prioritize long-term API stability and cannot risk breaking changes in production code
  • Applications heavily reliant on C++ features or complex C data types not easily wrapped in C interfaces

Pros & Cons

Pros

Cgo-Free FFI

Enables direct C function calls without Cgo dependencies, allowing pure Go compilation and eliminating cross-compilation hurdles, as emphasized in the motivation from Ebitengine.

Cross-Platform Simplicity

Supports tier 1 platforms like Linux, macOS, and Windows for easy cross-compilation without a C compiler, reducing build environment complexity.

Dynamic Runtime Loading

Allows loading symbols from shared objects (.so, .dylib, .dll) at runtime, enabling plugin-like functionality and flexible foreign library integration.

Build Efficiency

Reduces binary size and speeds up compilation by avoiding Cgo-generated wrapper functions, leading to smaller and faster builds as highlighted in the benefits.

Cons

Beta Stability Risks

Explicitly labeled as beta software with potential bugs and API breaking changes, making it risky for production use without careful version pinning.

Platform-Specific Complexities

Some architectures (e.g., FreeBSD, NetBSD) require special compiler flags or CGO_ENABLED=1, adding build process overhead and limiting pure Go benefits.

Limited Example Coverage

The provided example only handles macOS and Linux; other platforms need additional code, increasing initial setup effort for developers.

Frequently Asked Questions

Quick Stats

Stars3,651
Forks109
Contributors0
Open Issues13
Last commit1 day ago
CreatedSince 2022

Tags

#cgo#go-library#cross-compilation#system-calls#golang#dynamic-linking#shared-libraries#foreign-function-interface#go#low-level-programming

Built With

G
Go

Included in

Go169.1k
Auto-fetched 23 hours ago

Related Projects

gopsutilgopsutil

psutil for golang

Stars11,858
Forks1,670
Last commit1 day ago
gatusgatus

Automated developer-oriented status page with alerting and incident support

Stars11,163
Forks749
Last commit3 days ago
gofakeitgofakeit

Random fake data generator written in go

Stars5,359
Forks296
Last commit24 days ago
base64Captchabase64Captcha

captcha of base64 image string

Stars2,363
Forks309
Last commit8 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub