Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Max/Min for Slice of Structs #5

Open
azimjohn opened this issue Oct 22, 2020 · 1 comment
Open

Max/Min for Slice of Structs #5

azimjohn opened this issue Oct 22, 2020 · 1 comment

Comments

@azimjohn
Copy link

azimjohn commented Oct 22, 2020

Hello Dave,

Thanks for the great package!
I was looking for an elegant way of getting max/min of a slice of structs.

// Example
type benchmark struct {
	time       int
	size       int
}

// Given
var benchmarks []benchmark

/* 
  I sometimes need to find one of the following benchmarks
    - fastest (min time)
    - slowest (max time)
    - smallest (min size)
    - largest (max size)
*/
@davecheney
Copy link
Member

Hmm. I don’t see how to do that without using interface{}. If you can think of a way, please feel free to send a pr

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants