ffi-complex/main.go

package main

// #cgo CFLAGS: -g -Wall
/*
struct body {
  char *format;
  char *text;
};

struct page {
  char *title;
  struct body *body;
};
*/
import "C"

import (
	"fmt"
	"github.com/davecgh/go-spew/spew"
)

type body struct {
	format string
	text   string
}

type page struct {
	title string
	body  body
}

//export CCreate
func CCreate(p *C.struct_page) {
	Create(page{
		title: C.GoString(p.title),
		body: body{
			format: C.GoString(p.body.format),
			text:   C.GoString(p.body.text),
		},
	})
}

func Create(p page) {
	fmt.Println("requested to create a page:")
	spew.Dump(p)
}

func main() {}