https://github.com/go-utils/count
Easy counter
https://github.com/go-utils/count
counter go golang
Last synced: 8 months ago
JSON representation
Easy counter
- Host: GitHub
- URL: https://github.com/go-utils/count
- Owner: go-utils
- License: mit
- Created: 2020-11-05T10:14:59.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-04T19:53:22.000Z (over 5 years ago)
- Last Synced: 2023-07-28T18:22:45.484Z (almost 3 years ago)
- Topics: counter, go, golang
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What is this?
Easy counter
# Installation
```commandline
go get -u github.com/go-utils/count
```
# Usage
```go
import (
"fmt"
"github.com/go-utils/count"
)
func main() {
if cnt, err := count.Do("something", "a"); err == nil {
fmt.Println(cnt) // cnt = 0
}
if cnt, err := count.Do([]string{"1", "2", "3"}, "1"); err == nil {
fmt.Println(cnt) // cnt = 1
}
if cnt, err := count.Do([]int{1, 2, 3}, 1); err == nil {
fmt.Println(cnt) // cnt = 1
}
if cnt, err := count.Do("12321", "1"); err == nil {
fmt.Println(cnt) // cnt = 2
}
if cnt, err := count.Do([]interface{}{1, "2", 3, "4", nil, nil}, nil); err == nil {
fmt.Println(cnt) // cnt = 2
}
}
```
Check [Go Playground](https://play.golang.org/p/Yee5NWWEx-q)
# Support
`string`, `slice`, `array`
# License
[MIT](./LICENSE)