diff --git a/gps/constraint.go b/gps/constraint.go index f7c600316e..8c3f30afbb 100644 --- a/gps/constraint.go +++ b/gps/constraint.go @@ -6,7 +6,6 @@ package gps import ( "fmt" - "sort" "github.com/Masterminds/semver" "github.com/golang/dep/gps/internal/pb" @@ -375,7 +374,7 @@ func (m ProjectConstraints) overrideAll(pcm ProjectConstraints) (out []workingCo k++ } - sort.SliceStable(out, func(i, j int) bool { + sortSlice(out, func(i, j int) bool { return out[i].Ident.Less(out[j].Ident) }) return diff --git a/gps/lock_test.go b/gps/lock_test.go index 2833993eec..c688ec409a 100644 --- a/gps/lock_test.go +++ b/gps/lock_test.go @@ -6,7 +6,6 @@ package gps import ( "reflect" - "sort" "testing" ) @@ -21,7 +20,7 @@ func TestLockedProjectSorting(t *testing.T) { lps2 := make([]LockedProject, len(lps)) copy(lps2, lps) - sort.SliceStable(lps2, func(i, j int) bool { + sortSlice(lps2, func(i, j int) bool { return lps2[i].Ident().Less(lps2[j].Ident()) }) diff --git a/gps/sort_go_1_8.go b/gps/sort_go_1_8.go new file mode 100644 index 0000000000..410e179ed5 --- /dev/null +++ b/gps/sort_go_1_8.go @@ -0,0 +1,13 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.8 + +package gps + +import "sort" + +func sortSlice(slice interface{}, less func(i, j int) bool) { + sort.SliceStable(slice, less) +} diff --git a/gps/sort_pre_go_1_8.go b/gps/sort_pre_go_1_8.go new file mode 100644 index 0000000000..95b4c8569d --- /dev/null +++ b/gps/sort_pre_go_1_8.go @@ -0,0 +1,13 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.8 + +package gps + +import "sort" + +func sortSlice(slice interface{}, less func(i, j int) bool) { + sort.Slice(slice, less) +}