From 9328aecbf04e0860d8fd1f0d271aa9f79d52bd3d Mon Sep 17 00:00:00 2001 From: Christopher Grim Date: Wed, 20 Aug 2014 09:48:32 -0400 Subject: [PATCH] `go fmt` fixes --- config.go | 2 +- main.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config.go b/config.go index 56193ae..64152a7 100644 --- a/config.go +++ b/config.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "gopkg.in/yaml.v1" + "gopkg.in/yaml.v1" "io/ioutil" "log" "os" diff --git a/main.go b/main.go index 640f5b1..aaccf82 100644 --- a/main.go +++ b/main.go @@ -6,10 +6,10 @@ import ( "os" "os/exec" "regexp" + "sort" "strconv" "strings" "sync" - "sort" ) type Tag struct { @@ -58,9 +58,10 @@ func getInstances(config Config) (clouds CloudInstances) { } type SortByTagValue []StrMap + func (a SortByTagValue) Len() int { return len(a) } func (a SortByTagValue) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a SortByTagValue) Less(i, j int) bool { return a[i]["tag_value"] < a[j]["tag_value"]} +func (a SortByTagValue) Less(i, j int) bool { return a[i]["tag_value"] < a[j]["tag_value"] } func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap) { // Fuzzy matching, like SublimeText @@ -74,7 +75,7 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap if rHost.MatchString(cloud + tag.Value) { matched = append(matched, StrMap{ "cloud": cloud, - "addr": addr, + "addr": addr, "tag_name": tag.Name, "tag_value": tag.Value, }) @@ -84,10 +85,10 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap } } } - + sort.Sort(SortByTagValue(matched)) - return + return } func formatMatchedInstance(inst StrMap) string { @@ -104,7 +105,7 @@ func main() { match := getMatchedInstances(instances, hostname) - var matched_instance map[string]string + var matched_instance map[string]string if len(match) == 0 { fmt.Println("Can't find cloud instance, trying to connect anyway") @@ -137,7 +138,7 @@ func main() { fmt.Println("Connecting to instance:") fmt.Println(formatMatchedInstance(matched_instance)) } - + if len(args) == 0 { args = append(args, joinHostname(user, hostname)) } else {