Skip to content

Instantly share code, notes, and snippets.

@1000copy
Created April 13, 2014 04:17
Show Gist options
  • Save 1000copy/10568997 to your computer and use it in GitHub Desktop.
Save 1000copy/10568997 to your computer and use it in GitHub Desktop.
package main
/*
#include <stdlib.h>
*/
import "C"
import ("fmt")
func Random() int {
return int(C.random())
}
func Seed(i int) {
C.srandom(C.uint(i))
}
func main(){
fmt.Println("random from cgo:",Random());
}
// run : $go run cgo_demo.go
// output : random from cgo: 1804289383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment