From f486032fd7773c3493b6fd93a9c3847c9ac40176 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 2 Sep 2024 12:49:14 +0200 Subject: [PATCH] add `Area.String()` --- area.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/area.go b/area.go index 2bb7a01..bb01c88 100644 --- a/area.go +++ b/area.go @@ -1,8 +1,10 @@ package types +import "fmt" + type Area struct { - Pos1 *Pos - Pos2 *Pos + Pos1 *Pos `json:"pos1"` + Pos2 *Pos `json:"pos2"` } func NewArea(p1, p2 *Pos) *Area { @@ -10,6 +12,10 @@ func NewArea(p1, p2 *Pos) *Area { return &Area{Pos1: p1, Pos2: p2} } +func (a *Area) String() string { + return fmt.Sprintf("Area{%v,%v}", a.Pos1, a.Pos2) +} + // the inclusive size func (a *Area) Size() *Pos { return a.Pos2.Subtract(a.Pos1).Add(NewPos(1, 1, 1))