Upgrade to Pro — share decks privately, control downloads, hide ads and more …

puregoの活用例

 puregoの活用例

EbitengineぷちConf #2での発表資料

aethiopicuschan

March 28, 2024
Tweet

More Decks by aethiopicuschan

Other Decks in Programming

Transcript

  1. QVSFHPͱ͸ͳʹ͔ αϯϓϧίʔυ 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, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } var puts func(string) purego.RegisterLibFunc(&puts, libc, "puts") puts("Calling C from Go without Cgo!") } FCJUFOHJOFQVSFHPͷ3&"%.&͔ΒҾ༻