structs-guile/main.go

package main

// #cgo CFLAGS: -g -Wall
// #include "structs.h"
import "C"

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

type body struct {
	format string
	text   string
}

type page struct {
	title string
	body  body
}

func printer(p *C.struct_page) {
	for {
		time.Sleep(time.Second * 5)
		spew.Dump(p)
	}
}

//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),
		},
	})
	go printer(p)
}

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

func main() {}