mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-23 20:02:22 +00:00
fix: 修改2.7.2无法运行代码
This commit is contained in:
parent
32bda05b85
commit
4e2f1e8ab0
@ -54,11 +54,15 @@ cgo之所以存在的一大因素是为了方便在Go语言中接纳吸收过去
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
void printString(const char* s) {
|
void printString(const char* s) {
|
||||||
printf("%s", s);
|
printf("%s", s);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
func printString(s string) {
|
func printString(s string) {
|
||||||
cs := C.CString(s)
|
cs := C.CString(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user