From 2eff11bb2167ea98a4d81996056011eb4fb897d8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 23 Oct 2024 00:20:22 -0500 Subject: [PATCH] notsure Signed-off-by: Jeff Carr --- configfile/main.go | 3 +++ sampleData.go | 2 ++ storageinfo.go | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/configfile/main.go b/configfile/main.go index e0beec3..d54803d 100644 --- a/configfile/main.go +++ b/configfile/main.go @@ -44,6 +44,9 @@ func main() { json := aCluster.FormatJSON() fmt.Println(json) + data, _ := aCluster.MarshalJSON() + fmt.Println(string(data)) + text := aCluster.FormatTEXT() fmt.Println(text) } diff --git a/sampleData.go b/sampleData.go index 5a05377..02c6a0b 100644 --- a/sampleData.go +++ b/sampleData.go @@ -53,6 +53,8 @@ func CreateSampleCluster(total int) *Cluster { d.Cpus = 16 d.Memory = SetGB(256) } + info := StorageInfo{Capacity: 64} + d.Humantest = &info c.Droplets = append(c.Droplets, d) } diff --git a/storageinfo.go b/storageinfo.go index 993f5ef..4e1e9b0 100644 --- a/storageinfo.go +++ b/storageinfo.go @@ -14,6 +14,10 @@ func (s StorageInfo) MarshalJSON() ([]byte, error) { }) } +func (s StorageInfo) FormatJSON() string { + return fmt.Sprintf("\"capacity\": \"%d GB\"", s.Capacity) +} + // UnmarshalJSON custom unmarshals JSON into the StorageInfo struct func (s *StorageInfo) UnmarshalJSON(data []byte) error { var raw map[string]string