Структуры / Свойства

import (
    "fmt"
    "math"
)

//In Golang there are no properties
type square struct {
    side float64
}

func (s squareGetArea() float64 {
    return s.side * s.side
}

func (s *square) SetArea(area float64) {
    s.side = math.Sqrt(area)
}

var square2 = square{2.0}
var area = square2.GetArea()
//square.area is 4.0

square2.SetArea(9)
//square2.side is 3.0

fmt.Println(area)