Skip to content

Instantly share code, notes, and snippets.

@andydude
Created April 14, 2012 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andydude/2386741 to your computer and use it in GitHub Desktop.
Save andydude/2386741 to your computer and use it in GitHub Desktop.
// filename: cmd/foo/foo.go
package main
import simple "simple"
func main() {
d := simple.GetData()
simple.PutData(d)
}
data=hello
data=hello
#include <runtime.h>
void
simple·GetData(int8* data) {
data = runtime·malloc(6);
runtime·memmove(data, "hello", 6);
runtime·printf("data=%s\n", data);
FLUSH(&data);
}
void
simple·PutData(int8* data) {
runtime·printf("data=%s\n", data);
runtime·free(data);
}
package simple
func GetData() *byte
func PutData(*byte)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment