main.mx raw
1 package main
2
3 func main() {
4 s := []uint8{:0}
5 for i := int32(0); i < 100; i++ {
6 s = append(s, uint8(i))
7 }
8 if len(s) == 100 && s[0] == 0 && s[99] == 99 {
9 println("grow ok")
10 }
11
12 data := "hello world"
13 sub := data[6:11]
14 if sub == "world" {
15 println("subslice ok")
16 }
17
18 buf := []uint8{:0}
19 buf = append(buf, 'a')
20 buf = append(buf, 'b')
21 buf = append(buf, 'c')
22 piece := buf[1:3]
23 if piece[0] == 'b' && piece[1] == 'c' && len(piece) == 2 {
24 println("slice piece ok")
25 }
26 }
27