我正在关注本教程:https : //gobyexample.com/slices我在中间:package mainimport "fmt"func main() { s := make([]string, 3) fmt.Println("emp:", s) s[0] = "a" s[1] = "b" s[2] = "c" fmt.Println("set:", s) c := make([]string, len(s)) copy(c, s) fmt.Println("copy:", c) l := s[2:5] fmt.Println("sl1:", l)}当我突然遇到这个错误时:alex@alex-K43U:~/golang$ go run hello.goemp: [ ]set: [a b c]copy: [a b c]panic: runtime error: slice bounds out of rangegoroutine 1 [running]:main.main() /home/alex/golang/hello.go:19 +0x2bagoroutine 2 [syscall]:created by runtime.main /usr/lib/go/src/pkg/runtime/proc.c:221exit status 2这是什么意思?教程有误吗?我能做些什么来修复它?
- 2 回答
- 0 关注
- 197 浏览
添加回答
举报
0/150
提交
取消