https://github.com/nikgalushko/fx
Fx is a useful functional programming helpers.
https://github.com/nikgalushko/fx
generics go golang helper tool
Last synced: 5 months ago
JSON representation
Fx is a useful functional programming helpers.
- Host: GitHub
- URL: https://github.com/nikgalushko/fx
- Owner: nikgalushko
- License: mit
- Created: 2021-09-02T17:37:32.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-09T15:18:11.000Z (over 4 years ago)
- Last Synced: 2025-05-14T05:36:17.366Z (about 1 year ago)
- Topics: generics, go, golang, helper, tool
- Language: Go
- Homepage: https://nikgalushko.github.io/fx/
- Size: 42 KB
- Stars: 79
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fx
[](https://github.com/nikgalushko/fx/actions/workflows/go.yaml) [](https://coveralls.io/github/nikgalushko/fx?branch=main)
Fx is a useful functional programming helpers without using `interface{}` or reflect.
Support **only** Go 1.18+.
## Features
- Slice
- Each
- Collect
- Reduce
- Find
- Filter
- Every
- Some
- Contains
- Max
- Min
- GroupBy
- Sample
- SampleN
- Union
- Intersection
- Uniq
- IndexOf
- LastIndexOf
- Reverse
- Map
- Keys
- Values
- Each
- Filter
- Channel
- Merge
## Documentation
Documentation with examples can be found here: https://nikgalushko.github.io/fx/
## Installation
slice helpers `go get github.com/nikgalushko/fx/slice`
map helpers `go get github.com/nikgalushko/fx/kv`
channel helpers `go get github.com/nikgalushko/fx/ch`
## Usage
```go
import (
"fmt"
"github.com/nikgalushko/fx/kv"
"github.com/nikgalushko/fx/slice"
)
type (
ID string
Attribute struct {
Value string
}
)
func main() {
m := map[ID]Attribute{
ID("1"): {Value: "blah"},
ID("1861"): {Value: "!"},
ID("1234"): {Value: "yeah"},
}
fmt.Println("ids", kv.Keys(m), "contains special", slice.Contains(kv.Values(m), Attribute{Value: "!"}))
}
```