pkg/str/str_panic_test.go

23 lines
375 B
Go
Raw Normal View History

2023-09-18 15:51:20 +08:00
package str
import (
"fmt"
"testing"
)
func TestStrUse(t *testing.T) {
const NoModify = "Don't edit this string. "
str := fmt.Sprintf(NoModify+"%s", "Do something")
bs := S2B(str)
bs[0] = 'L'
t.Log(str)
// 不可以对字面量量声明的字符串进行这种修改
t.Run("painc", func(t *testing.T) {
bs = S2B(NoModify)
bs[0] = 'L'
t.Log(NoModify)
})
}