golang101
Repos
1

Events

Created at 3 hours ago
Created at 3 hours ago
Created at 2 days ago
Created at 2 days ago
Created at 2 days ago
Created at 3 days ago
Created at 4 days ago
Created at 5 days ago
Created at 6 days ago
Created at 6 days ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago
Created at 1 week ago

add 1.20 contents; fix https://github.com/go101/go101/issues/242

Merge branch 'master' of github.com:golang101/golang101

Created at 1 week ago
Created at 1 week ago
issue comment
《Go 细节和小技巧 101》电子书下载链接

北京联通,亲测有效。 翻墙,亲测有效。

Created at 2 weeks ago
closed issue
《Go 细节和小技巧 101》3.4 从字符串转换来的字节型切片的容量是未指定的

代码如下:

func addPrefixes2(prefixStr string, bss [][]byte) {
	var prefix = []byte(prefixStr)
	fmt.Println(len(prefix), cap(prefix)) // -> 2, 32   // line 3
	for i, bs := range bss {
		bss[i] = append(append([]byte{}, prefix...), bs...)
	}
	// fmt.Printf("prefix: %s\nprefix: %#v\n", prefix, prefix)  // line 7
	// len(prefix), cap(prefix) -> 2, 8
}

line3 输出 2, 32 取消line 7 注释后,line3 输出 2, 8
想不明白,求大佬指教

Created at 2 weeks ago
issue comment
《Go 细节和小技巧 101》3.4 从字符串转换来的字节型切片的容量是未指定的

标题已经说明了原因:从字符串转换来的字节型切片的容量是未指定的。;) cap 可以是任何不小于2的值。 thx

Created at 2 weeks ago
Created at 2 weeks ago
Created at 2 weeks ago