viper-app/pkg/str/str_panic_test.go

23 lines
375 B
Go
Raw Permalink Normal View History

package str
2023-02-03 16:18:31 +08:00
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)
})
}