Skip to content

Commit

Permalink
add cgo sample
Browse files Browse the repository at this point in the history
  • Loading branch information
kicool committed Apr 10, 2012
1 parent 3384e1a commit d0a3518
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cgo/helloc.go
@@ -0,0 +1,23 @@
package main

/*
#include <stdio.h>
#include <stdlib.h>
void myprint(char* s) {
printf("%s", s);
}
*/
import "C"

import "unsafe"

func Example() {
cs := C.CString("Hello from stdio\n")
C.myprint(cs)
C.free(unsafe.Pointer(cs))
}

func main() {
Example()
}

0 comments on commit d0a3518

Please sign in to comment.