ZhangZhihui's Blog  

 

 

 

 

 

We need to keep two things in mind while using the substring operation in Go. 

First, the interval provided is based on the number of bytes, not the number of runes. 

Second, a substring operation may lead to a memory leak as the resulting substring will share the same backing array as the initial string. The solutions to prevent this case from happening are to perform a string copy manually or to use strings.Clone from Go 1.18.

posted on 2024-02-21 11:35  ZhangZhihuiAAA  阅读(12)  评论(0编辑  收藏  举报