LoginSignup
0
0

More than 5 years have passed since last update.

Initializing struct fields in Go

Posted at
package main

import "fmt"

type Vertex struct {
        X int
        Y int
        S string
}

func main() {
        v := Vertex{1, 2, "3"}
        v.X = 4
        fmt.Println(v.X, v.Y,v.S)
}
4 2 3
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0