在golang中,为什么`a:= [] int32(“ hello”)`起作用,而不是`a:= [] int(“ hello”)`起作用?

The tile is my question. In Go, why does a := []int32("hello") work but not a := []int("hello")?

Because the spec allows converting a string value to a rune slice ([]rune), and rune is an alias to int32 (they are one and the same). This is what the first conversion does:

Converting a value of a string type to a slice of runes type yields a slice containing the individual Unicode code points of the string.

Basically a string => []rune conversion decodes the UTF-8 bytes of the text (this is how Go stores strings in memory) to Unicode code points (runes).

And the spec does not allow converting a string to an int slice, so the second is a compile-time error.