summaryrefslogtreecommitdiff
path: root/configfile
diff options
context:
space:
mode:
Diffstat (limited to 'configfile')
-rw-r--r--configfile/Makefile3
-rw-r--r--configfile/main.go35
2 files changed, 22 insertions, 16 deletions
diff --git a/configfile/Makefile b/configfile/Makefile
index 4f609e1..a52de6a 100644
--- a/configfile/Makefile
+++ b/configfile/Makefile
@@ -2,6 +2,9 @@ build:
GO111MODULE=off go build
./configfile
+goimports:
+ goimports -w *.go
+
prep:
go get -v -t -u
diff --git a/configfile/main.go b/configfile/main.go
index abc306a..e0beec3 100644
--- a/configfile/main.go
+++ b/configfile/main.go
@@ -1,13 +1,17 @@
package main
-import "log"
-import "bytes"
-import "os"
-import "bufio"
-import "io/ioutil"
+import (
+ "bufio"
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
-import "google.golang.org/protobuf/proto"
-import pb "go.wit.com/lib/protobuf/virtbuf"
+ "google.golang.org/protobuf/proto"
+
+ pb "go.wit.com/lib/protobuf/virtbuf"
+)
//
// saves entries in a config file
@@ -21,7 +25,7 @@ func main() {
log.Fatalln("Error reading file:", err)
}
- var aCluster pb.Cluster
+ var aCluster pb.Cluster
if err := proto.Unmarshal(in, &aCluster); err != nil {
log.Fatalln("Failed to parse droplet:", err)
}
@@ -29,20 +33,19 @@ func main() {
log.Println(aCluster.String())
// show the droplets to STDOUT
for _, d := range aCluster.Droplets {
- log.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
+ fmt.Println("\tdroplet =", d.Hostname, "preffered host:", d.PreferredHypervisor)
}
// show the hypervisors to STDOUT
for _, h := range aCluster.Hypervisors {
- log.Println("\thypervisor =", h.Hostname, h.GetMemoryPrintable())
+ fmt.Println("\thypervisor =", h.Hostname, h.GetMemoryPrintable())
}
- b, err := aCluster.MarshalJSON()
- if err != nil {
- log.Println("json failed")
- } else {
- log.Println(string(b))
- }
+ json := aCluster.FormatJSON()
+ fmt.Println(json)
+
+ text := aCluster.FormatTEXT()
+ fmt.Println(text)
}
func marshalWriteToFile(myWriter *bufio.Writer, c *pb.Cluster) {