MCPcopy
hub / github.com/spf13/pflag / sortFlags

Function sortFlags

flag.go:229–242  ·  view source on GitHub ↗

sortFlags returns the flags as a slice in lexicographical sorted order.

(flags map[NormalizedName]*Flag)

Source from the content-addressed store, hash-verified

227
228// sortFlags returns the flags as a slice in lexicographical sorted order.
229func sortFlags(flags map[NormalizedName]*Flag) []*Flag {
230 list := make(sort.StringSlice, len(flags))
231 i := 0
232 for k := range flags {
233 list[i] = string(k)
234 i++
235 }
236 list.Sort()
237 result := make([]*Flag, len(list))
238 for i, name := range list {
239 result[i] = flags[NormalizedName(name)]
240 }
241 return result
242}
243
244// SetNormalizeFunc allows you to add a function which can translate flag names.
245// Flags added to the FlagSet will be translated and then when anything tries to

Callers 2

VisitAllMethod · 0.85
VisitMethod · 0.85

Calls 1

NormalizedNameTypeAlias · 0.85

Tested by

no test coverage detected