yan*_*ory 1 loops go
我是Golang的新手,但我希望不会有像这样基本的问题.
package main
import "fmt"
func main() {
s := make([]int, 0)
s = append(s, 1)
for len(s) != 0 {
j := len(s) - 1
top, s := s[j], s[:j]
fmt.Printf("top = %+v\n", top)
fmt.Printf("s = %+v\n", s)
fmt.Printf("len(s) = %+v\n", len(s))
}
}
此命令不会退出,只是打印
len(s) = 0
top = 1
s = []
len(s) = 0
top = 1
s = []
len(s) = ^C
我发现这令人惊叹; 我究竟做错了什么?从语法上讲,基于https://tour.golang.org/flowcontrol/3,一切似乎都可以.