Skip to content

Commit

Permalink
bug: correct pipeline, contraints package and example functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ledongthuc committed Mar 15, 2022
1 parent db1d343 commit dd7dc85
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 22 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ jobs:
- name: Install dependencies
run: |
go version
cd server; go mod tidy
go mod tidy
- name: Run build
run: |
cd server
go build .
- name: Run testing
run: |
cd server
go test -v
- name: Run vetting
run: |
cd server
go vet -v ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Goterators
[![Built with WeBuild](https://raw.githubusercontent.com/webuild-community/badge/master/svg/WeBuild.svg)](https://webuild.community) [![Go Reference](https://pkg.go.dev/badge/github.com/ledongthuc/goterators.svg)](https://pkg.go.dev/github.com/ledongthuc/goterators)
[![Built with WeBuild](https://raw.githubusercontent.com/webuild-community/badge/master/svg/WeBuild.svg)](https://webuild.community) [![Go Reference](https://pkg.go.dev/badge/github.com/ledongthuc/goterators.svg)](https://pkg.go.dev/github.com/ledongthuc/goterators) [![goterators-Build](https://github.com/ledongthuc/goterators/actions/workflows/build.yml/badge.svg)](https://github.com/ledongthuc/goterators/actions/workflows/build.yml)

![goterators-Thumbnail](https://user-images.githubusercontent.com/1828895/147876484-5bc7cfd0-5f14-4889-a3f0-64cb307b7765.png)

Expand Down
2 changes: 1 addition & 1 deletion constraints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

type Number interface {
constraints.Integer | constraints.Float
Expand Down
2 changes: 1 addition & 1 deletion count.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

// Count returns number of checking item exists in source list
func Count[T constraints.Ordered](source []T, checkedItem T) (result int) {
Expand Down
2 changes: 1 addition & 1 deletion count_list.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

// CountList returns sub-list counter of input sub-list that want to count from source list.
func CountList[T constraints.Ordered](source []T, checkedItems []T) []int {
Expand Down
2 changes: 1 addition & 1 deletion every_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestEveryNotValid(t *testing.T) {
}
}

func ExampleEvery(t *testing.T) {
func ExampleEvery() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
everyValid := Every(testSource, func(item int) bool { return item <= 20 })
fmt.Println("Every: ", everyValid)
Expand Down
2 changes: 1 addition & 1 deletion exist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestExistString(t *testing.T) {
}
}

func ExampleExist(t *testing.T) {
func ExampleExist() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
fmt.Println("Exist: ", Exist(testSource, 15))
}
2 changes: 1 addition & 1 deletion filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestFilterString(t *testing.T) {
}
}

func ExampleFilter(t *testing.T) {
func ExampleFilter() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
filteredItems := Filter(testSource, func(item int) bool {
return item%2 == 0
Expand Down
2 changes: 1 addition & 1 deletion find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestFindString(t *testing.T) {
}
}

func ExampleFind(t *testing.T) {
func ExampleFind() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
firstFoundItem, index, _ := Find(testSource, func(item int) bool {
return item%10 == 0
Expand Down
2 changes: 1 addition & 1 deletion flat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestFlatNested(t *testing.T) {
}
}

func ExampleFlat(t *testing.T) {
func ExampleFlat() {
testSource := [][]int{{1, 2, 3, 4}, {5, 6, 7, 8, 9, 10, 11}, {12, 13, 14, 15, 16, 17, 18, 19}, {20}, {}}
items := Flat(testSource)
fmt.Println("Flat: ", items)
Expand Down
2 changes: 1 addition & 1 deletion foreach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func testForEach[K comparable](source []K, t *testing.T) {
}
}

func ExampleForEach(t *testing.T) {
func ExampleForEach() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
ForEach(testSource, func(item int) {
fmt.Println("ForEach: ", item)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/ledongthuc/goterators

go 1.18

require golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7 h1:jynE66seADJbyWMUdeOyVTvPtBZt7L6LJHupGwxPZRM=
golang.org/x/exp v0.0.0-20220314205449-43aec2f8a4e7/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
2 changes: 1 addition & 1 deletion group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestGroup(t *testing.T) {
}
}

func ExampleGroup(t *testing.T) {
func ExampleGroup() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
groups := Group(testSource, func(item int) int {
return item % 2
Expand Down
2 changes: 1 addition & 1 deletion map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestMap(t *testing.T) {
}
}

func ExampleMap(t *testing.T) {
func ExampleMap() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
mappedItems := Map(testSource, func(item int) string {
return fmt.Sprintf("Item-%d", item)
Expand Down
2 changes: 1 addition & 1 deletion max.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

// Max find largest value from source list
func Max[T constraints.Ordered](source []T) (result T, err error) {
Expand Down
2 changes: 1 addition & 1 deletion min.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

// Min find smallest value from source list
func Min[T constraints.Ordered](source []T) (result T, err error) {
Expand Down
2 changes: 1 addition & 1 deletion mode.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goterators

import "constraints"
import "golang.org/x/exp/constraints"

// Mode return a value that appears most often in the source list.
func Mode[T constraints.Ordered](source []T) (T, int) {
Expand Down
2 changes: 1 addition & 1 deletion reduce_right_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestReduceRight(t *testing.T) {
}
}

func ExampleReduceRight(t *testing.T) {
func ExampleReduceRight() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
result := ReduceRight(testSource, []int{}, func(previous []int, current int, index int, list []int) []int {
return append(previous, current)
Expand Down
2 changes: 1 addition & 1 deletion reduce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestReduceSimulateMap(t *testing.T) {
}
}

func ExampleReduce(t *testing.T) {
func ExampleReduce() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
result := Reduce(testSource, 0, func(previous int, current int, index int, list []int) int {
return previous + current
Expand Down
2 changes: 1 addition & 1 deletion some_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestSomeNotValid(t *testing.T) {
}
}

func ExampleSome(t *testing.T) {
func ExampleSome() {
testSource := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
result := Some(testSource, func(item int) bool {
return item%2 == 0
Expand Down

0 comments on commit dd7dc85

Please sign in to comment.