Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.27.x
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: latest
args: --timeout=30m
Expand All @@ -33,20 +37,20 @@ jobs:
name: Test
strategy:
matrix:
go-version: [ 1.20.x, 1.21.x ]
go-version: [ 1.27.x ]
platform: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Run tests with coverage
run: go test -shuffle=on -v -race -coverprofile=coverage -covermode=atomic
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1.5.0
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
file: ./coverage
files: ./coverage
flags: unittests
42 changes: 29 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
linters-settings:
nakedret:
max-func-lines: 0 # Disallow any unnamed return statement

version: "2"
linters:
enable:
- unused
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- nakedret
- gofmt
- rowserrcheck
- unconvert
- goimports
- unparam
settings:
staticcheck:
checks:
- all
- "-QF1001" # I'm a math noob
nakedret:
max-func-lines: 0 # Disallow any unnamed return statement
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
6 changes: 3 additions & 3 deletions binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (invoke errorHandlerInvoker) Invoke(args []interface{}) ([]reflect.Value, e

// ensureNotPointer panics if the given value is a pointer.
func ensureNotPointer(model interface{}) {
if reflect.TypeOf(model).Kind() == reflect.Ptr {
if reflect.TypeOf(model).Kind() == reflect.Pointer {
panic("binding: pointer can not be accepted as binding model")
}
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func mapForm(
files map[string][]*multipart.FileHeader,
errs Errors,
) Errors {
if obj.Kind() == reflect.Ptr {
if obj.Kind() == reflect.Pointer {
obj = obj.Elem()
}
typ := obj.Type()
Expand All @@ -219,7 +219,7 @@ func mapForm(
continue
}

if typeField.Type.Kind() == reflect.Ptr && typeField.Anonymous {
if typeField.Type.Kind() == reflect.Pointer && typeField.Anonymous {
structField.Set(reflect.New(typeField.Type.Elem()))
errs = mapForm(structField.Elem(), form, files, errs)
if reflect.DeepEqual(structField.Elem().Interface(), reflect.Zero(structField.Elem().Type()).Interface()) {
Expand Down
8 changes: 4 additions & 4 deletions binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestJSON(t *testing.T) {

fastInvokerHandler := func(c flamego.Context, errs Errors) {
c.ResponseWriter().WriteHeader(http.StatusBadRequest)
_, _ = c.ResponseWriter().Write([]byte(fmt.Sprintf("Oops! Error occurred: %v", errs[0].Err)))
_, _ = fmt.Fprintf(c.ResponseWriter(), "Oops! Error occurred: %v", errs[0].Err)
}

tests := []struct {
Expand Down Expand Up @@ -398,7 +398,7 @@ func TestYAML(t *testing.T) {
}
fastInvokerHandler := func(c flamego.Context, errs Errors) {
c.ResponseWriter().WriteHeader(http.StatusBadRequest)
_, _ = c.ResponseWriter().Write([]byte(fmt.Sprintf("Oops! Error occurred: %v", errs[0].Err)))
_, _ = fmt.Fprintf(c.ResponseWriter(), "Oops! Error occurred: %v", errs[0].Err)
}
tests := []struct {
name string
Expand Down Expand Up @@ -853,7 +853,7 @@ func TestForm(t *testing.T) {

fastInvokerHandler := func(c flamego.Context, errs Errors) {
c.ResponseWriter().WriteHeader(http.StatusBadRequest)
_, _ = c.ResponseWriter().Write([]byte(fmt.Sprintf("Oops! Error occurred: %v", errs[0].Err)))
_, _ = fmt.Fprintf(c.ResponseWriter(), "Oops! Error occurred: %v", errs[0].Err)
}

tests := []struct {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func TestMultipartForm(t *testing.T) {

fastInvokerHandler := func(c flamego.Context, errs Errors) {
c.ResponseWriter().WriteHeader(http.StatusBadRequest)
_, _ = c.ResponseWriter().Write([]byte(fmt.Sprintf("Oops! Error occurred: %v", errs[0].Err)))
_, _ = fmt.Fprintf(c.ResponseWriter(), "Oops! Error occurred: %v", errs[0].Err)
}

tests := []struct {
Expand Down
Loading