parent
662e3a5849
commit
2eff11bb21
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue