Go踩过的坑之make slice panic: runtime error: makeslice: len out of range
重现
func main(){
var peek []byte
//var len=1000*1000*1000 //success
//var len=1000*1000*1000*1000// fatal error: out of memory allocating heap arena metadata
var len=1000*1000*1000*1000*1000 //panic: runtime error: makeslice: len out of range
//var len=-8//panic: runtime error: makeslice: len out of range
peek = append(peek, make([]byte, len)...)
fmt.Println("end......")
}
网友评论