mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 20:52:22 +00:00
23 lines
425 B
Go
23 lines
425 B
Go
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
package main
|
|
|
|
//#cgo CFLAGS: -I./mystring
|
|
//#cgo LDFLAGS: -L${SRCDIR}/mystring -lmystring
|
|
//
|
|
//#include "mystring.h"
|
|
//#include <stdlib.h>
|
|
import "C"
|
|
import (
|
|
"fmt"
|
|
"unsafe"
|
|
)
|
|
|
|
func main() {
|
|
cs := C.make_string(C.CString("hello"))
|
|
defer C.free(unsafe.Pointer(cs))
|
|
|
|
fmt.Println(C.GoString(cs))
|
|
}
|