Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions github/gen-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"go/token"
"log"
"os"
"sort"
"slices"
"strings"
"text/template"
)
Expand Down Expand Up @@ -182,7 +182,9 @@ func (t *templateData) dump() error {
}

// Sort getters by ReceiverType.FieldName.
sort.Sort(byName(t.Getters))
slices.SortStableFunc(t.Getters, func(a, b *getter) int {
return strings.Compare(a.sortVal, b.sortVal)
})

processTemplate := func(tmpl *template.Template, filename string) error {
var buf bytes.Buffer
Expand Down Expand Up @@ -344,12 +346,6 @@ type getter struct {
ArrayType bool
}

type byName []*getter

func (b byName) Len() int { return len(b) }
func (b byName) Less(i, j int) bool { return b[i].sortVal < b[j].sortVal }
func (b byName) Swap(i, j int) { b[i], b[j] = b[j], b[i] }

const source = `// Copyright {{.Year}} The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
Expand Down
Loading