Skip to content

Instantly share code, notes, and snippets.

Created Dec 25, 2013
What would you like to do?
package main
#include <stdio.h>
void test(unsigned char* b) {
printf("fetch: %s\n", b);
b[0] = 'b';
b[1] = 'a';
b[2] = 'r';
import "C"
import (
func main() {
buf := []byte("foo")
fmt.Printf("original: %s\n", buf)
data := (*reflect.SliceHeader)(unsafe.Pointer(&buf)).Data
fmt.Printf("result: %s\n", buf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment