github.com/hbdrawn/golang@v0.0.0-20141214014649-6b835209aba2/doc/progs/cgo2.go (about) 1 // skip 2 3 // Copyright 2012 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 package rand2 7 8 /* 9 #include <stdlib.h> 10 */ 11 import "C" 12 13 func Random() int { 14 var r C.int = C.rand() 15 return int(r) 16 } 17 18 // STOP OMIT 19 func Seed(i int) { 20 C.srand(C.uint(i)) 21 } 22 23 // END OMIT