mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 12:32:21 +00:00
26 lines
405 B
Go
26 lines
405 B
Go
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
package main
|
|
|
|
/*
|
|
#include <stdio.h>
|
|
|
|
void cgoPuts(char* s);
|
|
|
|
static void SayHello(const char* s) {
|
|
cgoPuts((char*)(s));
|
|
}
|
|
*/
|
|
import "C"
|
|
import "fmt"
|
|
|
|
func main() {
|
|
C.SayHello(C.CString("Hello, World\n"))
|
|
}
|
|
|
|
//export cgoPuts
|
|
func cgoPuts(s *C.char) {
|
|
fmt.Print(C.GoString(s))
|
|
}
|