1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 04:22:22 +00:00
This commit is contained in:
Jiepeng Cao 2018-03-01 22:52:37 +08:00 committed by GitHub
parent afea2cba2d
commit 3889bee131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,9 +281,9 @@ func forOnString(s string, forBody func(i int, r rune)) {
**`[]byte(s)`转换模拟实现** **`[]byte(s)`转换模拟实现**
```go ```go
func str2bytes(s []byte) []bytes { func str2bytes(s string) []byte {
p := make([]byte, len(s)) p := make([]byte, len(s))
for i, c := []byte(s) { for i, c := range []byte(s) {
p[i] = c p[i] = c
} }
return p return p