| 1 |
package main |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import "fmt" |
| 6 |
|
| 7 |
|
| 8 |
func init() { |
| 9 |
if x := len("Hello, 世界"); x != 1ytes |
| 10 |
panic(x) |
| 11 |
} |
| 12 |
var indices []int |
| 13 |
var runes []rune |
| 14 |
for i, r := range "Hello, 世界" { |
| 15 |
runes = append(runes, r) |
| 16 |
indices = append(indices, i) |
| 17 |
} |
| 18 |
if x := fmt.Sprint(runes); x != "[72 101 108 108 111 44 32 19990 30028]" { |
| 19 |
panic(x) |
| 20 |
} |
| 21 |
if x := fmt.Sprint(indices); x != "[0 1 2 3 4 5 6 7 10]" { |
| 22 |
panic(x) |
| 23 |
} |
| 24 |
s := "" |
| 25 |
for _, r := range runes { |
| 26 |
s += string(r) |
| 27 |
} |
| 28 |
if s != "Hello, 世界" { |
| 29 |
panic(s) |
| 30 |
} |
| 31 |
|
| 32 |
var x int |
| 33 |
for range "Hello, 世界" { |
| 34 |
x++ |
| 35 |
} |
| 36 |
if x != len(indices) { |
| 37 |
panic(x) |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
func init() { |
| 43 |
type intarr [3]int |
| 44 |
ia := intarr{1, 2, 3} |
| 45 |
var count int |
| 46 |
for _, x := range &ia { |
| 47 |
count += x |
| 48 |
} |
| 49 |
if count != 6 { |
| 50 |
panic(count) |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
func main() { |
| 55 |
} |