Skip to content

Commit

Permalink
go fmt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bookest committed Aug 20, 2014
1 parent e815953 commit 9328aec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"gopkg.in/yaml.v1"
"gopkg.in/yaml.v1"
"io/ioutil"
"log"
"os"
Expand Down
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"os"
"os/exec"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"sort"
)

type Tag struct {
Expand Down Expand Up @@ -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
Expand All @@ -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,
})
Expand All @@ -84,10 +85,10 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap
}
}
}

sort.Sort(SortByTagValue(matched))

return
return
}

func formatMatchedInstance(inst StrMap) string {
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9328aec

Please sign in to comment.