https://github.com/ebitengine/purego Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} ebitengine / purego Public * Notifications * Fork 9 * Star 298 License Apache-2.0 license 298 stars 9 forks Star Notifications * Code * Issues 2 * Pull requests 1 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights ebitengine/purego This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 4 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/e] Use Git or checkout with SVN using the web URL. [gh repo clone ebiten] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @TotallyGamerJet TotallyGamerJet add tests for dlfcn (#96) ... cb589c5 Feb 12, 2023 add tests for dlfcn (#96) This commit adds two tests. One comes from an example which wasn't really an example of using purego but more of a test to make sure fakecgo was functioning properly. Now it's an actual test. The other is a simple test that calls into libc cb589c5 Git stats * 74 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows .github/workflows: use Go 1.20 (#92) February 6, 2023 14:27 example/objc add tests for dlfcn (#96) February 12, 2023 15:02 internal internal/fakecgo: correct the explanation of using closure calls (#85 ) January 6, 2023 20:10 objc objc: generic Send and SendSuper (#90) January 8, 2023 20:51 .gitignore .github/workflows: add test.yml (#30) August 30, 2022 04:24 LICENSE first commit May 14, 2022 20:47 README.md Fix typo CGO_ENABED. (#95) February 12, 2023 13:35 cgo.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 dlfcn.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 dlfcn_darwin.go Move dlfcn.h constants under platform specific file (#53) October 23, 2022 14:21 dlfcn_linux.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 dlfcn_nocgo_linux.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 dlfcn_stubs.s purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 dlfcn_test.go add tests for dlfcn (#96) February 12, 2023 15:02 dummy.go all: fix build tags (#56) October 30, 2022 21:02 func.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 go.mod all: drop 1.16 and 1.17 (#55) October 29, 2022 22:05 go_runtime.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 is_ios.go all: fix build tags (#56) October 30, 2022 21:02 nocgo.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 sys_darwin_amd64.s use crosscall2 from runtime/cgo (#80) December 14, 2022 10:09 sys_darwin_arm64.s cleanup assembly (#81) December 16, 2022 10:39 sys_linux_amd64.s purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 sys_linux_arm64.s purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 syscall.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 syscall_cgo_linux.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 syscall_darwin.go purego: get ABIInternal wrapper using closure (#75) December 2, 2022 13:28 syscall_nocgo_linux.go purego: add Linux support amd64 & arm64 (#66) November 24, 2022 14:29 syscall_test.go add tests for dlfcn (#96) February 12, 2023 15:02 syscall_windows.go Update syscall_windows.go (#42) September 10, 2022 00:10 zcallback_darwin_amd64.s purego: add Objective-C runtime bindings (#11) July 25, 2022 00:27 zcallback_darwin_arm64.s purego: add Objective-C runtime bindings (#11) July 25, 2022 00:27 View code purego Example External Code README.md purego Go Reference A library for calling C functions from Go without Cgo. Example package main import ( "fmt" "runtime" "github.com/ebitengine/purego" ) func getSystemLibrary() string { switch runtime.GOOS { case "darwin": return "/usr/lib/libSystem.B.dylib" case "linux": return "libc.so.6" default: panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS)) } } func main() { libc := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL) if err := purego.Dlerror(); err != "" { panic(err) } var puts func(string) purego.RegisterLibFunc(&puts, libc, "puts") puts("Calling C from from Go without Cgo!") } Then to run: CGO_ENABLED=0 go run main.go External Code Purego uses code that originates from the Go runtime. These files are under the BSD-3 License that can be found in the Go Source. This is a list of the copied files: * zcallback_darwin_*.s from package runtime * internal/abi/abi_*.h from package runtime/cgo * internal/fakecgo/asm_GOARCH.s from package runtime/cgo * internal/fakecgo/callbacks.go from package runtime/cgo * internal/fakecgo/go_GOOS_GOARCH.go from package runtime/cgo * internal/fakecgo/iscgo.go from package runtime/cgo * internal/fakecgo/setenv.go from package runtime/cgo About No description, website, or topics provided. Resources Readme License Apache-2.0 license Stars 298 stars Watchers 5 watching Forks 9 forks Releases 4 tags Packages 0 No packages published Used by 2 * @gucio321 @gucio321 / saper-go * @hajimehoshi @hajimehoshi / ebiten Contributors 4 * @TotallyGamerJet TotallyGamerJet * @hajimehoshi hajimehoshi Hajime Hoshi * @iurisilvio iurisilvio Iuri de Silvio * @cuonglm cuonglm Cuong Manh Le Languages * Assembly 63.8% * Go 34.3% * C 1.9% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.