package state import ( "errors" "math" ) var ErrOutOfBounds = errors.New("coordinate was out of bounds") func (x *StorageCoordinatesPB) ToGo() (StorageCoordinates, error) { if x.Line > math.MaxUint8 || x.Cell > math.MaxUint8 { return StorageCoordinates{}, ErrOutOfBounds } return StorageCoordinates{ Line: uint8(x.Line), Cell: uint8(x.Cell), }, nil } func (s StorageCoordinates) ToPB() *StorageCoordinatesPB { return &StorageCoordinatesPB{ Line: uint32(s.Line), Cell: uint32(s.Cell), } }