1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-23 20:02:22 +00:00

Merge pull request #437 from quocanh1897/master

Fix error example ch2-03
This commit is contained in:
chai2010 2019-06-26 21:40:59 +08:00 committed by GitHub
commit bdeb00d17c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -322,8 +322,9 @@ type SliceHeader struct {
```go ```go
/* /*
static char arr[10]; #include <string.h>
static char *s = "Hello"; char arr[10];
char *s = "Hello";
*/ */
import "C" import "C"
import ( import (
@ -347,7 +348,7 @@ func main() {
s0Hdr.Len = int(C.strlen(C.s)) s0Hdr.Len = int(C.strlen(C.s))
sLen := int(C.strlen(C.s)) sLen := int(C.strlen(C.s))
s1 := string((*[31]byte)(unsafe.Pointer(&C.s[0]))[:sLen:sLen]) s1 := string((*[31]byte)(unsafe.Pointer(C.s))[:sLen:sLen])
} }
``` ```