From 34818f875d6a46b6dfd245273943887e46d83d76 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 13 Aug 2015 21:00:52 -0700 Subject: [PATCH] Remove Version string from json prints, rename first-time.go to verify-runtime.go --- main.go | 2 +- print-structs.go | 18 +++--------------- first-time.go => verify-runtime.go | 6 +++--- 3 files changed, 7 insertions(+), 19 deletions(-) rename first-time.go => verify-runtime.go (97%) diff --git a/main.go b/main.go index 7639f87d..4f0d6544 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func registerBefore(ctx *cli.Context) error { errorIf(err) } - firstTimeRun() + verifyMCRuntime() // Migrate any old version of config / state files to newer format. migrate() diff --git a/print-structs.go b/print-structs.go index e30c09d1..416d6f28 100644 --- a/print-structs.go +++ b/print-structs.go @@ -29,7 +29,6 @@ import ( // DiffJSONMessage json container for diff messages type DiffJSONMessage struct { - Version string `json:"version"` FirstURL string `json:"first"` SecondURL string `json:"second"` Diff string `json:"diff"` @@ -50,7 +49,6 @@ func (s diffV1) String() string { return message } diffMessage := DiffJSONMessage{} - diffMessage.Version = "1.0.0" diffMessage.FirstURL = s.firstURL diffMessage.SecondURL = s.secondURL diffMessage.Diff = s.diffType @@ -63,7 +61,6 @@ func (s diffV1) String() string { // SessionJSONMessage json container for session messages type SessionJSONMessage struct { - Version string `json:"version"` SessionID string `json:"sessionid"` Time string `json:"time"` CommandType string `json:"command-type"` @@ -78,7 +75,6 @@ func (s sessionV2) String() string { return message + "\n" } sessionMesage := SessionJSONMessage{ - Version: s.Header.Version, SessionID: s.SessionID, Time: s.Header.When.Local().Format(printDate), CommandType: s.Header.CommandType, @@ -93,7 +89,6 @@ func (s sessionV2) String() string { // Content container for content message structure type Content struct { - Version string `json:"version"` Filetype string `json:"type"` Time string `json:"last-modified"` Size string `json:"size"` @@ -113,7 +108,6 @@ func (c Content) String() string { }() return message + "\n" } - c.Version = "1.0.0" jsonMessageBytes, err := json.MarshalIndent(c, "", "\t") if err != nil { panic(err) @@ -123,10 +117,9 @@ func (c Content) String() string { // CopyMessage container for file copy messages type CopyMessage struct { - Version string `json:"version"` - Source string `json:"source"` - Target string `json:"target"` - Length int64 `json:"length"` + Source string `json:"source"` + Target string `json:"target"` + Length int64 `json:"length"` } // String string printer for copy message @@ -134,7 +127,6 @@ func (c CopyMessage) String() string { if !globalJSONFlag { return fmt.Sprintf("‘%s’ -> ‘%s’\n", c.Source, c.Target) } - c.Version = "1.0.0" copyMessageBytes, err := json.MarshalIndent(c, "", "\t") if err != nil { panic(err) @@ -144,7 +136,6 @@ func (c CopyMessage) String() string { // MirrorMessage container for file mirror messages type MirrorMessage struct { - Version string `json:"version"` Source string `json:"source"` Targets []string `json:"targets"` Length int64 `json:"length"` @@ -155,7 +146,6 @@ func (s MirrorMessage) String() string { if !globalJSONFlag { return fmt.Sprintf("‘%s’ -> ‘%s’\n", s.Source, s.Targets) } - s.Version = "1.0.0" mirrorMessageBytes, err := json.MarshalIndent(s, "", "\t") if err != nil { panic(err) @@ -165,7 +155,6 @@ func (s MirrorMessage) String() string { // ShareMessage container for share messages type ShareMessage struct { - Version string `json:"version"` Expires time.Duration `json:"expire-seconds"` PresignedURL string `json:"presigned-url"` } @@ -175,7 +164,6 @@ func (s ShareMessage) String() string { if !globalJSONFlag { return fmt.Sprintf("Succesfully generated shared URL with expiry %s, please share: %s\n", s.Expires, s.PresignedURL) } - s.Version = "1.0.0" shareMessageBytes, err := json.MarshalIndent(s, "", "\t") if err != nil { panic(err) diff --git a/first-time.go b/verify-runtime.go similarity index 97% rename from first-time.go rename to verify-runtime.go index c316bf13..bf6d418e 100644 --- a/first-time.go +++ b/verify-runtime.go @@ -89,7 +89,7 @@ func (v1 version) LessThan(v2 version) bool { return false } -func checkGolangVersion() { +func checkGolangRuntimeVersion() { v1 := newVersion(getNormalizedGolangVersion()) switch runtime.GOOS { case "windows": @@ -105,7 +105,7 @@ func checkGolangVersion() { } } -func firstTimeRun() { +func verifyMCRuntime() { if !isMcConfigExists() { if err := createMcConfigDir(); err != nil { console.Fatalf("Unable to create ‘mc’ config folder. %s\n", err) @@ -120,5 +120,5 @@ func firstTimeRun() { err := createSessionDir() fatalIf(err) } - checkGolangVersion() + checkGolangRuntimeVersion() }