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

Spreading world by encouragement of cgo

linyows
October 17, 2017

Spreading world by encouragement of cgo

Oct 17, 2017 @fukuoka.go#9 でお話しした資料です

linyows

October 17, 2017
Tweet

More Decks by linyows

Other Decks in Technology

Transcript

  1. GVLVPLBHP package main /* #cgo pkg-config: onigmo #include <stdlib.h> #include

    <string.h> #include <onigmo.h> */ import "C" import "fmt" fun main() { fmt.Println(Version()) // Output: 6.1.3 } func Version() string { return C.GoString(C.onig_version()) } package main // typedef int (*intFunc) (); // // int bridge_int_func(intFunc f) { // return f(); // } // // int fortytwo() { // return 42; // } import "C" import "fmt" func main() { f := C.intFunc(C.fortytwo) fmt.Println(int(C.bridge_int_func(f))) // Output: 42 }
  2. GVLVPLBHP ؾΛ͚ͭΔͱ͜Ζ ▸ (PϙΠϯλ΍ϝϞϦͷڞ༗ʹϧʔϧ͕͋Δ ▸ ϙΠϯλͷϧʔϧҧ൓ΛಈతʹνΣοΫ͍ͯͯ͠Ϋϥογϡ͢Δ ▸ (0%&#6(DHPDIFDL $VJOUQUS ▸

    ΋ͪΖΜ$ଆ͸($͞Εͳ͍͠$GSFF͠ͳ͍ͱϝϞϦϦʔΫ͢Δ ▸ εϨουηʔϑͰͳ͍΋ͷ͸͔ͬ͠ΓTZODNVUFY͢Δ ▸ $(0ʹॻ͍ͨ$͸ผϑΝΠϧ͔Βࢀরग़དྷͳ͍