From 447a2ffe714df92ca6b66bf7a4f0b702627eb5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 19 Feb 2025 23:31:53 +0100 Subject: [PATCH 1/2] Depend on go 1.21, build and test with later versions --- .github/workflows/test.yaml | 6 +++--- go.mod | 2 +- util/util_unsafe_go120.go | 24 ------------------------ 3 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 util/util_unsafe_go120.go diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 129cbca..006a18d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,16 +5,16 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.21.x, 1.22.x] + go-version: [1.22.x, 1.23.x, 1.24.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run lints uses: golangci/golangci-lint-action@v6 with: diff --git a/go.mod b/go.mod index dd98e31..af77632 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/yuin/goldmark -go 1.19 +go 1.21 diff --git a/util/util_unsafe_go120.go b/util/util_unsafe_go120.go deleted file mode 100644 index d6be534..0000000 --- a/util/util_unsafe_go120.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:build !appengine && !js && !go1.21 -// +build !appengine,!js,!go1.21 - -package util - -import ( - "reflect" - "unsafe" -) - -// BytesToReadOnlyString returns a string converted from given bytes. -func BytesToReadOnlyString(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} - -// StringToReadOnlyBytes returns bytes converted from given string. -func StringToReadOnlyBytes(s string) (bs []byte) { - sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) - bh := (*reflect.SliceHeader)(unsafe.Pointer(&bs)) - bh.Data = sh.Data - bh.Cap = sh.Len - bh.Len = sh.Len - return -} From c2db7e9f3265de9fa1ea08558f2fcdfd5984ba77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 19 Feb 2025 23:33:36 +0100 Subject: [PATCH 2/2] Fix linter --- .golangci.yml | 2 +- parser/delimiter.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 39fe61d..69ad57d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - deadline: 10m + timeout: 10m issues: exclude-use-default: false diff --git a/parser/delimiter.go b/parser/delimiter.go index d097e3f..93b32de 100644 --- a/parser/delimiter.go +++ b/parser/delimiter.go @@ -111,7 +111,7 @@ func NewDelimiter(canOpen, canClose bool, length int, char byte, processor Delim } // ScanDelimiter scans a delimiter by given DelimiterProcessor. -func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcessor) *Delimiter { +func ScanDelimiter(line []byte, before rune, minimum int, processor DelimiterProcessor) *Delimiter { i := 0 c := line[i] j := i @@ -120,7 +120,7 @@ func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcess } for ; j < len(line) && c == line[j]; j++ { } - if (j - i) >= min { + if (j - i) >= minimum { after := rune(' ') if j != len(line) { after = util.ToRune(line, j)