Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

From http://blog.golang.org/2011/03/c-go-cgo.html :

  package rand
  
  /*
  #include <stdlib.h>
  */
  import "C"
  
  func Random() int {
     return int(C.random())
  }
  
  func Seed(i int) {
     C.srandom(C.uint(i))
  }
So calling C functions from Go is very easy. However the other way is not supported, AFAIK.


Calling Go from C is supported, but is not quite as straightforward. You can also use SWIG.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: