diff options
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/go/test.go | 8 | ||||
| -rw-r--r-- | src/cmd/nm/nm.go | 24 |
2 files changed, 4 insertions, 28 deletions
diff --git a/src/cmd/go/test.go b/src/cmd/go/test.go index 138d46c381..4b65c1ccdc 100644 --- a/src/cmd/go/test.go +++ b/src/cmd/go/test.go @@ -1397,7 +1397,7 @@ func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) error { } } ex := doc.Examples(f) - sort.Sort(byOrder(ex)) + sort.Slice(ex, func(i, j int) bool { return ex[i].Order < ex[j].Order }) for _, e := range ex { *doImport = true // import test file whether executed or not if e.Output == "" && !e.EmptyOutput { @@ -1419,12 +1419,6 @@ func checkTestFunc(fn *ast.FuncDecl, arg string) error { return nil } -type byOrder []*doc.Example - -func (x byOrder) Len() int { return len(x) } -func (x byOrder) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byOrder) Less(i, j int) bool { return x[i].Order < x[j].Order } - var testmainTmpl = template.Must(template.New("main").Parse(` package main diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go index 462c4c510f..4384af8fae 100644 --- a/src/cmd/nm/nm.go +++ b/src/cmd/nm/nm.go @@ -103,11 +103,11 @@ func nm(file string) { switch *sortOrder { case "address": - sort.Sort(byAddr(syms)) + sort.Slice(syms, func(i, j int) bool { return syms[i].Addr < syms[j].Addr }) case "name": - sort.Sort(byName(syms)) + sort.Slice(syms, func(i, j int) bool { return syms[i].Name < syms[j].Name }) case "size": - sort.Sort(bySize(syms)) + sort.Slice(syms, func(i, j int) bool { return syms[i].Size > syms[j].Size }) } w := bufio.NewWriter(os.Stdout) @@ -131,21 +131,3 @@ func nm(file string) { } w.Flush() } - -type byAddr []objfile.Sym - -func (x byAddr) Len() int { return len(x) } -func (x byAddr) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byAddr) Less(i, j int) bool { return x[i].Addr < x[j].Addr } - -type byName []objfile.Sym - -func (x byName) Len() int { return len(x) } -func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byName) Less(i, j int) bool { return x[i].Name < x[j].Name } - -type bySize []objfile.Sym - -func (x bySize) Len() int { return len(x) } -func (x bySize) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x bySize) Less(i, j int) bool { return x[i].Size > x[j].Size } |
