Answers for "inizialiyze struct di struct golang"

Go
-1

inizialiyze struct di struct golang

package main

import "fmt"

func main() {
    result := Result{
        Name: "I am Groot",
        Objects: []MyStruct{
            {
                MyField: 1,
            },
            {
                MyField: 2,
            },
            {
                MyField: 3,
            },
        },
    }

    fmt.Println(result)

}

type MyStruct struct {
    MyField int
}

type Result struct {
    Name    string
    Objects []MyStruct
}
Posted by: Guest on December-04-2020

Browse Popular Code Answers by Language