Skip to content

Commit a0a32a7

Browse files
committed
vector marshaling + removes enumeration constants
1 parent 95844a9 commit a0a32a7

File tree

5 files changed

+13
-73
lines changed

5 files changed

+13
-73
lines changed

types/base.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import (
77
)
88

99
type Vector2 struct {
10-
X float64 `json:"x"`
11-
Y float64 `json:"y"`
10+
X float64
11+
Y float64
12+
}
13+
14+
func (v Vector2) MarshalJSON() ([]byte, error) {
15+
return json.Marshal([]float64{v.X, v.Y})
1216
}
1317

1418
type Vector2Wrapper struct {
@@ -29,9 +33,13 @@ func (v *Vector2Wrapper) UnmarshalJSON(data []byte) error {
2933
}
3034

3135
type Vector3 struct {
32-
X float64 `json:"x"`
33-
Y float64 `json:"y"`
34-
Z float64 `json:"z"`
36+
X float64
37+
Y float64
38+
Z float64
39+
}
40+
41+
func (v Vector3) MarshalJSON() ([]byte, error) {
42+
return json.Marshal([]float64{v.X, v.Y, v.Z})
3543
}
3644

3745
type Vector3Wrapper struct {
@@ -52,24 +60,8 @@ func (v *Vector3Wrapper) UnmarshalJSON(data []byte) error {
5260
}
5361

5462
type Color string
55-
5663
type MetricImperialUnit string
57-
58-
const (
59-
MetricMM MetricImperialUnit = "mm"
60-
MetricCM MetricImperialUnit = "cm"
61-
MetricM MetricImperialUnit = "m"
62-
MetricF MetricImperialUnit = "f"
63-
)
64-
6564
type FloorMetric string
66-
67-
const (
68-
FloorM FloorMetric = "m"
69-
FloorT FloorMetric = "t"
70-
FloorF FloorMetric = "f"
71-
)
72-
7365
type Slug string
7466

7567
type Header struct {

types/corridor.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import "encoding/json"
44

55
type Temperature string
66

7-
const (
8-
COLD Temperature = "cold"
9-
WARM Temperature = "warm"
10-
)
11-
127
type Corridor struct {
138
Header
149
Content string `json:"content"`

types/device.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import "encoding/json"
44

55
type DeviceOrientation string
66

7-
const (
8-
DeviceFront DeviceOrientation = "front"
9-
DeviceRear DeviceOrientation = "rear"
10-
DeviceFrontflipped DeviceOrientation = "frontflipped"
11-
DeviceRearflipped DeviceOrientation = "rearflipped"
12-
)
13-
147
type DeviceTemplate = RackTemplate
158

169
type Device struct {

types/rack.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,10 @@ import (
66
)
77

88
type RackOrientation string
9-
10-
const (
11-
RackFront RackOrientation = "front"
12-
RackRear RackOrientation = "rear"
13-
RackLeft RackOrientation = "left"
14-
RackRight RackOrientation = "right"
15-
)
16-
179
type RackUnit string
18-
19-
const (
20-
RackMM RackUnit = "mm"
21-
RackCM RackUnit = "cm"
22-
RackM RackUnit = "m"
23-
RackU RackUnit = "u"
24-
RackOU RackUnit = "ou"
25-
RackF RackUnit = "f"
26-
)
27-
2810
type LabelPosition string
29-
30-
const (
31-
LabelFront LabelPosition = "front"
32-
LabelRear LabelPosition = "rear"
33-
LabelFrontrear LabelPosition = "frontrear"
34-
LabelTop LabelPosition = "top"
35-
LabelRight LabelPosition = "right"
36-
LabelLeft LabelPosition = "left"
37-
)
38-
3911
type ComponentOrientation string
4012

41-
const (
42-
ComponentHorizontal ComponentOrientation = "horizontal"
43-
ComponentVertical ComponentOrientation = "vertical"
44-
)
45-
4613
type Component struct {
4714
Factor string `json:"factor,omitempty"`
4815
Color *Color `json:"color,omitempty"`

types/site.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import "encoding/json"
44

55
type SiteOrientation string
66

7-
const (
8-
EN SiteOrientation = "EN"
9-
NW SiteOrientation = "NW"
10-
WS SiteOrientation = "WS"
11-
SE SiteOrientation = "SE"
12-
)
13-
147
type Site struct {
158
Header
169
Orientation *SiteOrientation `json:"orientation,omitempty"`

0 commit comments

Comments
 (0)