Skip to content
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Go
on:
push:
branches: [ master ]
branches: [ master, v2 ]
paths:
- '**.go'
- 'go.mod'
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.24.x
go-version: 1.26.x
- name: Check Go module tidiness
shell: bash
run: |
Expand All @@ -42,7 +42,7 @@ jobs:
exit 1
fi
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --timeout=30m
Expand All @@ -51,7 +51,7 @@ jobs:
name: Test
strategy:
matrix:
go-version: [ 1.24.x ]
go-version: [ 1.26.x ]
platform: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
53 changes: 35 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
linters-settings:
staticcheck:
checks: [
"all",
"-SA1019" # There are valid use cases of strings.Title
]
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:
govet:
disable:
# printf: non-constant format string in call to fmt.Errorf (govet)
# showing up since golangci-lint version 1.60.1
- printf
staticcheck:
checks:
- all
- "-QF1001" # I'm a math noob
- "-ST1016" # Some legit code uses this pattern
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$
3 changes: 1 addition & 2 deletions commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package git
import (
"bytes"
"io"
"io/ioutil"
"net/http"
"strings"
"sync"
Expand Down Expand Up @@ -154,7 +153,7 @@ func (c *Commit) isImageFile(blob *Blob, err error) (bool, error) {
N: int64(buf.Cap()),
}

err = blob.Pipeline(stdout, ioutil.Discard)
err = blob.Pipeline(stdout, io.Discard)
if err != nil {
return false, err
}
Expand Down
3 changes: 1 addition & 2 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"strconv"
"strings"
)
Expand Down Expand Up @@ -482,7 +481,7 @@ func (p *diffParser) parse() (*Diff, error) {
// Check if reached maximum number of files
if p.maxFiles > 0 && len(diff.Files) >= p.maxFiles {
diff.isIncomplete = true
_, _ = io.Copy(ioutil.Discard, p)
_, _ = io.Copy(io.Discard, p)
break
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gogs/git-module/v2

go 1.24.0
go 1.26.0

require github.com/stretchr/testify v1.11.1

Expand Down
5 changes: 2 additions & 3 deletions hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package git

import (
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -235,11 +234,11 @@ func (h *Hook) Content() string {
// memory copy of the content as well.
func (h *Hook) Update(content string) error {
h.content = strings.TrimSpace(content)
h.content = strings.Replace(h.content, "\r", "", -1)
h.content = strings.ReplaceAll(h.content, "\r", "")

if err := os.MkdirAll(path.Dir(h.path), os.ModePerm); err != nil {
return err
} else if err = ioutil.WriteFile(h.path, []byte(h.content), os.ModePerm); err != nil {
} else if err = os.WriteFile(h.path, []byte(h.content), os.ModePerm); err != nil {
return err
}

Expand Down
3 changes: 1 addition & 2 deletions hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package git

import (
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -43,7 +42,7 @@ func TestHook_Update(t *testing.T) {
t.Fatal(err)
}

p, err := ioutil.ReadFile(path)
p, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading