mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-22 06:55:20 +00:00
Make sorting compatible with go >= 1.6
This commit is contained in:
10
harness/build.go
Executable file → Normal file
10
harness/build.go
Executable file → Normal file
@@ -23,6 +23,12 @@ import (
|
|||||||
|
|
||||||
var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"")
|
var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"")
|
||||||
|
|
||||||
|
type ByString []*TypeInfo
|
||||||
|
|
||||||
|
func (c ByString) Len() int { return len(c) }
|
||||||
|
func (c ByString) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
||||||
|
func (c ByString) Less(i, j int) bool { return c[i].String() < c[j].String() }
|
||||||
|
|
||||||
// Build the app:
|
// Build the app:
|
||||||
// 1. Generate the the main.go file.
|
// 1. Generate the the main.go file.
|
||||||
// 2. Run the appropriate "go build" command.
|
// 2. Run the appropriate "go build" command.
|
||||||
@@ -44,11 +50,11 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) {
|
|||||||
|
|
||||||
// Sort controllers so that file generation is reproducible
|
// Sort controllers so that file generation is reproducible
|
||||||
controllers := sourceInfo.ControllerSpecs()
|
controllers := sourceInfo.ControllerSpecs()
|
||||||
sort.SliceStable(controllers, func(i, j int) bool { return controllers[i].String() < controllers[j].String() })
|
sort.Stable(ByString(controllers))
|
||||||
|
|
||||||
// Generate two source files.
|
// Generate two source files.
|
||||||
templateArgs := map[string]interface{}{
|
templateArgs := map[string]interface{}{
|
||||||
"Controllers": sourceInfo.ControllerSpecs(),
|
"Controllers": controllers,
|
||||||
"ValidationKeys": sourceInfo.ValidationKeys,
|
"ValidationKeys": sourceInfo.ValidationKeys,
|
||||||
"ImportPaths": calcImportAliases(sourceInfo),
|
"ImportPaths": calcImportAliases(sourceInfo),
|
||||||
"TestSuites": sourceInfo.TestSuites(),
|
"TestSuites": sourceInfo.TestSuites(),
|
||||||
|
|||||||
Reference in New Issue
Block a user