それでは実際に実行してみましょう。
https://go.dev/play/p/omWI1XFl5RE
ackagepackage main
import "fmt"
func main() {
variadicExample()
}
func variadicExample(s ...string) {
fmt.Println(s[0])
fmt.Println(s[3])
}
実行結果
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.variadicExample({0x0, 0x485320, 0xc0000001a0})
/tmp/sandbox399561776/prog.go:10 +0xef
main.main()
/tmp/sandbox399561776/prog.go:6 +0x25
Program exited.