26 lines
379 B
Go
26 lines
379 B
Go
package learning
|
|
|
|
import "fmt"
|
|
|
|
type Vertex struct {
|
|
X int
|
|
Y int
|
|
}
|
|
|
|
type SomeStruct struct {
|
|
X int
|
|
Y string
|
|
Z bool
|
|
U float32
|
|
J float64
|
|
}
|
|
|
|
func StructLearning() {
|
|
v := Vertex{1, 2}
|
|
vv := SomeStruct{}
|
|
p := &v
|
|
v.Y = 123 // setting Y value of v via '.'
|
|
p.X = 1e9 // setting X value of v via pointer to v. Syntax sugar for (*p).X
|
|
fmt.Println(v)
|
|
fmt.Println(vv)
|
|
}
|