Code review comment for lp:~hduran-8/juju-core/apiworker_force_local_connection

Revision history for this message
Wayne Witzel III (wwitzel3) wrote :

https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go
File state/api/apiclient.go (right):

https://codereview.appspot.com/100810045/diff/40001/state/api/apiclient.go#newcode111
state/api/apiclient.go:111:
We should use the built-in sort here.

http://golang.org/pkg/sort/

type LocalhostFirst []string

func (a LocalhostFirst) Len() int { return len(a) }
func (a LocalhostFirst) Swap(i int, j int) { a[i], a[j] = a[j], a[i] }
func (a LocalhostFirst) Less(i int, j int) bool { return
strings.HasPrefix(a[i], "localhost") }

return sort.Sort(LocalhostFirst(addrs))

https://codereview.appspot.com/100810045/

« Back to merge proposal