go create new instance of struct
type Person struct {
Name string
}
func main() {
var me Person
me.name = "mattalui"
}
go create new instance of struct
type Person struct {
Name string
}
func main() {
var me Person
me.name = "mattalui"
}
init struct go
type Student struct {
Name string
Age int
}
var a Student // a == Student{"", 0}
a.Name = "Alice" // a == Student{"Alice", 0}
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
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us