Re: [go-nuts] Self-referential generics?

2022-04-10 Thread Shawn Smith
11:23 AM Axel Wagner wrote: > You can use > > type Comparable[T any] interface { > Cmp(other T) int > } > > then *big.Int implements `Comparable[*big.Int]` and you can write > > func cmpSort[T Comparable[T]](x []C) { … } > > On Sun, Apr 10, 2022 at 7:48 PM Sha

[go-nuts] Self-referential generics?

2022-04-10 Thread Shawn Smith
// ... imagine some comparison sort algorithm func cmpSort[C Cmpable](x []C) { for i, val := range x { if i == 0 { continue } _ = val.Cmp(x[i-1]) } } // Cmpable should include big.Int, big.Float, big.Rat, by virtue of their Cmp methods. So how do i def

[go-nuts] Speeding up Go Report Card

2016-09-02 Thread Shawn Smith
Hi, I'm one of the maintainers of Go Report Card http://goreportcard.com/ and I am looking for advice on how to make it faster. Basically we run a series of checks (gofmt, vet, etc.) on your Go repository and provide a grade based on how many errors each check returns. Each check runs in a sep