Query and manipulate Go slices and collections using SQL-like methods.
Written in pure Go with no dependencies, tested with 100% code coverage.
Find average age of students over 20.
Import your []Student .
|
results := From(students).
|
Find those over 20. So we make type assertion to our input type. |
Where(func (s interface{}) bool { |
Select their ages. |
Select(func (s interface{}) interface{} { |
Find the average. |
Average()
|
Count websites that have a favicon.ico.
urls := make(chan interface{}) |
|
Convert domain names to full URLs. |
go func(domains []string) { |
Let's run the following in parallel. Request favicon for each domain. |
go func() { |
Count websites. |
FromChannel(results).CountWith(func(r interface{}) bool { |
If you have suggestions or improvements, feel free to contact or submit a pull request. All contributions are welcomed.
This library is brought you by Alexander (kalan) Kalankhodzhaev and @ahmetalpbalkan.