you're looking for strings.EqualFold, most likely.
On Tue, Apr 30, 2013 at 2:45 PM, Graham MacDonald
<
grahamam...@gmail.com> wrote:
> I have a string in a struct (os.FileInfo actually), and I want a case
> insensitive sort. I've implemented the sort interface for the using ToLower
> and the default string comparison as so:
>
> type ByPath []os.FileInfo
>
> func (s ByPath) Len() int { return len(s) }
> func (s ByPath) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
> func (s ByPath) Less(i, j int) bool {
> return strings.ToLower(s[i].Name()) < strings.ToLower(s[j].Name())
> }
>
> Is there a better way?
>
> Thanks,
> Graham
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>