mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 04:22:22 +00:00
Merge pull request #437 from quocanh1897/master
Fix error example ch2-03
This commit is contained in:
commit
bdeb00d17c
@ -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])
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user