Skip to content

Commit

Permalink
Merge pull request #18 from minimum2scp/features/golang-1.8
Browse files Browse the repository at this point in the history
Golang 1.8
  • Loading branch information
kamito authored Feb 20, 2017
2 parents f46b0b7 + 06bf1bf commit 7c36cde
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ addons:
packages:
- glide
go:
- 1.6.4
- 1.8
- tip
install:
- go get github.com/golang/lint/golint
Expand Down Expand Up @@ -36,4 +36,4 @@ deploy:
repo: minimum2scp/geco
tags: true
branch: master
condition: "${TRAVIS_GO_VERSION} = 1.6.4"
condition: "${TRAVIS_GO_VERSION} = 1.8"
34 changes: 6 additions & 28 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,6 @@ type configRoot struct {
Core configCore `json:"core"`
}

// sort Projects by projectId
type projectsByID []*cloudresourcemanager.Project

func (by projectsByID) Len() int {
return len(by)
}
func (by projectsByID) Less(i, j int) bool {
return by[i].ProjectId < by[j].ProjectId
}
func (by projectsByID) Swap(i, j int) {
by[i], by[j] = by[j], by[i]
}

// sort Instances by selfLink
type instancesBySelfLink []*compute.Instance

func (by instancesBySelfLink) Len() int {
return len(by)
}
func (by instancesBySelfLink) Less(i, j int) bool {
return by[i].SelfLink < by[j].SelfLink
}
func (by instancesBySelfLink) Swap(i, j int) {
by[i], by[j] = by[j], by[i]
}

// cache
type cache struct {
CacheDir string
Expand Down Expand Up @@ -282,8 +256,12 @@ func doCache(cliCtx *cli.Context) {
}

// sort projects, instances
sort.Sort(projectsByID(c.Projects))
sort.Sort(instancesBySelfLink(c.Instances))
sort.Slice(c.Projects, func(i, j int) bool {
return c.Projects[i].ProjectId < c.Projects[j].ProjectId
})
sort.Slice(c.Instances, func(i, j int) bool {
return c.Instances[i].SelfLink < c.Instances[j].SelfLink
})

saveCache(c)
log.Println("saved cache.")
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const version string = "2.0.7"
const version string = "2.0.8"

0 comments on commit 7c36cde

Please sign in to comment.