美文网首页Golang 入门资料+笔记
Go踩过的坑之make slice panic: runtime

Go踩过的坑之make slice panic: runtime

作者: 五岁小孩 | 来源:发表于2021-03-11 09:00 被阅读0次

    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......")
    }
    

    相关文章

      网友评论

        本文标题:Go踩过的坑之make slice panic: runtime

        本文链接:https://www.haomeiwen.com/subject/inugxltx.html