package pkg import ( "crypto/md5" "fmt" "os" "testing" ) func TestFileMD5(t *testing.T) { t.Log(FileMD5("test.txt")) readFile, err := os.ReadFile("test.txt") if err != nil { t.Fatal(err) } t.Log(fmt.Sprintf("%x", md5.Sum(readFile))) } func TestS(t *testing.T) { t.Run("复用数组", func(t *testing.T) { fns := []string{"11", "22"} for idx, fn := range fns { if idx == 0 { fns = fns[0:0] } t.Log(len(fns), cap(fns)) fns = append(fns, fn+"::") } t.Log(len(fns), cap(fns), fns) }) t.Run("for range 改变数组", func(t *testing.T) { arr := []int{11, 22, 33} for idx, v := range arr { if idx < len(arr)-1 { arr[idx+1]++ } t.Log(v) } }) }