Skip to content

Instantly share code, notes, and snippets.


Joel Williams flowonyx

  • Eshowe, South Africa
View GitHub Profile
flowonyx / filter.go
Last active May 13, 2016
Filter a slice based on any field in the element using reflection
View filter.go
import (
// Filter takes a slice of structs that have a field with the given fieldName
// and uses that to filter based on value. The parameter, keep, determines
// whether the filter process keeps only the items filtered (true) or removes
// them (false).