进入[] int符文

for pos, char := range s {
        fmt.Println( utf8.RuneLen(char) )
}

This code works in Go (pre v1) but doesn't work in Go1.

cannot use char (type []int) as type rune in function argument

I ran go fix which updated the "utf8" import to "unicode/utf8", but now I get the previous err.

The docs for rune mention a trivial conversion will resolve this error.

The code you posted works in Go1. Assuming s is a string.

Make sure you aren't unexpectedly introducing or using some other variable named char which has type []int, and make sure there are no typos in your code which would lead to unexpected usage of a different variable.