Golang-我可以有一个带有数组成员的结构吗? [关闭]

is it possible to have an array as a member of a struct in golang without specifying the array size? If so, how do I do it?

you can have a slice or you can have a fixed size array defined at runtime

package main

import "fmt"

func main() {
    mystruct := struct {
        array [3]int
        slice [] int
    }{
        [...]int{1, 2, 3},
        []int{1, 2, 3, 4, 5},
    }
    fmt.Println(mystruct)
}