From 729f50116f3cce70ea2764ac59fd6a4fcf077707 Mon Sep 17 00:00:00 2001 From: Alexandre E Souza Date: Wed, 24 Jul 2024 17:34:24 -0300 Subject: [PATCH 1/3] feat: update go version and update pipe function --- go.mod | 4 ++-- v1/pipe.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 193022c..9786e71 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/devalexandre/pipe -go 1.20 +go 1.22 -require github.com/devalexandre/gofn v1.0.1 // indirect +require github.com/devalexandre/gofn v1.0.1 diff --git a/v1/pipe.go b/v1/pipe.go index 7e19213..5ad5d11 100644 --- a/v1/pipe.go +++ b/v1/pipe.go @@ -11,7 +11,7 @@ type Pipeline func(...interface{}) (interface{}, error) // Pipe creates a pipeline from a series of functions. func Pipe(fs ...interface{}) Pipeline { return func(initialArgs ...interface{}) (interface{}, error) { - var currentArgs []interface{} = initialArgs + currentArgs := initialArgs for _, f := range fs { fnVal := reflect.ValueOf(f) fnType := fnVal.Type() @@ -19,7 +19,7 @@ func Pipe(fs ...interface{}) Pipeline { // Prepare the input arguments for the current function. in := make([]reflect.Value, numIn) - for i := 0; i < numIn; i++ { + for i := range numIn { if i < len(currentArgs) { in[i] = reflect.ValueOf(currentArgs[i]) } else if i < len(initialArgs) { // Allow passing manual arguments if not enough currentArgs. @@ -34,7 +34,7 @@ func Pipe(fs ...interface{}) Pipeline { results := fnVal.Call(in) // Assume the last function call results will be used as next input. - currentArgs = []interface{}{} // Reset currentArgs for next function. + currentArgs = nil // Reset currentArgs for next function. for _, result := range results { if result.Type().Implements(reflect.TypeOf((*error)(nil)).Elem()) { if !result.IsNil() { // If the result is an error, return it. From 0d4aedc102d7a3ca9049dae277b515827114ee12 Mon Sep 17 00:00:00 2001 From: Alexandre E Souza Date: Wed, 24 Jul 2024 18:41:07 -0300 Subject: [PATCH 2/3] feat: update go version and update pipe function --- .github/workflows/go.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d9e4bed..c789812 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,21 +5,20 @@ name: Go on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.22" - - name: Test - run: go test -v ./... + - name: Test + run: go test -v ./... From cbd2910e11c7e61443888920a79fbcc70deddd0e Mon Sep 17 00:00:00 2001 From: Alexandre E Souza Date: Wed, 24 Jul 2024 18:45:42 -0300 Subject: [PATCH 3/3] feat: add golangci --- .github/workflows/golangci-lint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..682c180 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,23 @@ +name: golangci-lint +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59