diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b773473f..4933c13f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: fail-fast: false matrix: pg: ['14', '15', '16', '17', '18'] - go: ['1.21', '1.25'] + go: ['1.21', '1.26'] steps: - uses: 'actions/checkout@v6' - uses: 'actions/setup-go@v6' @@ -54,7 +54,7 @@ jobs: steps: - uses: 'actions/checkout@v6' - uses: 'actions/setup-go@v6' - with: {go-version: '1.25'} + with: {go-version: '1.26'} - name: 'Start PostgreSQL' run: | docker compose up pg18 -d --wait || { @@ -80,7 +80,7 @@ jobs: # steps: # - uses: 'actions/checkout@v6' # - uses: 'actions/setup-go@v6' - # with: {go-version: '1.25'} + # with: {go-version: '1.26'} # - name: 'Start PostgreSQL' # run: | # docker compose up pg18 -d --wait || { @@ -107,7 +107,7 @@ jobs: # fail-fast: false # matrix: # pg: ['18'] - # go: ['1.18', '1.25'] + # go: ['1.18', '1.26'] # steps: # - uses: 'actions/checkout@v6' # - uses: 'douglascamata/setup-docker-macos-action@v1' @@ -138,9 +138,9 @@ jobs: # strategy: # fail-fast: false # matrix: - # #go: ['1.18', '1.25'] + # #go: ['1.18', '1.26'] # pg: ['18'] - # go: ['1.25'] + # go: ['1.26'] # steps: # - uses: 'actions/checkout@v6' # - uses: 'Vampire/setup-wsl@v6' diff --git a/array.go b/array.go index 910f335e..8164d5da 100644 --- a/array.go +++ b/array.go @@ -388,7 +388,7 @@ FoundType: func (a GenericArray) Scan(src any) error { dpv := reflect.ValueOf(a.A) switch { - case dpv.Kind() != reflect.Ptr: + case dpv.Kind() != reflect.Pointer: return fmt.Errorf("pq: destination %T is not a pointer to array or slice", a.A) case dpv.IsNil(): return fmt.Errorf("pq: destination %T is nil", a.A) diff --git a/conn.go b/conn.go index b1cf83cd..a28803fb 100644 --- a/conn.go +++ b/conn.go @@ -831,7 +831,7 @@ func (cn *conn) CheckNamedValue(nv *driver.NamedValue) error { return driver.ErrSkip } t := v.Type() - for t.Kind() == reflect.Ptr { + for t.Kind() == reflect.Pointer { t, v = t.Elem(), v.Elem() } diff --git a/encode_test.go b/encode_test.go index 5ad2d429..b99293e6 100644 --- a/encode_test.go +++ b/encode_test.go @@ -5,6 +5,7 @@ import ( "database/sql" "fmt" "regexp" + "strings" "testing" "time" @@ -641,7 +642,7 @@ func TestTextByteSliceToInt(t *testing.T) { db := pqtest.MustDB(t) expected := 12345678 - b := []byte(fmt.Sprintf("%d", expected)) + b := fmt.Appendf(nil, "%d", expected) row := db.QueryRow("SELECT $1::int", b) var result int @@ -879,21 +880,21 @@ func TestFormatAndParseTimestamp(t *testing.T) { } func BenchmarkAppendEscapedText(b *testing.B) { - longString := "" + var longString strings.Builder for i := 0; i < 100; i++ { - longString += "123456789\n" + longString.WriteString("123456789\n") } for i := 0; i < b.N; i++ { - appendEscapedText(nil, longString) + appendEscapedText(nil, longString.String()) } } func BenchmarkAppendEscapedTextNoEscape(b *testing.B) { - longString := "" + var longString strings.Builder for i := 0; i < 100; i++ { - longString += "1234567890" + longString.WriteString("1234567890") } for i := 0; i < b.N; i++ { - appendEscapedText(nil, longString) + appendEscapedText(nil, longString.String()) } } diff --git a/error.go b/error.go index 234d39e2..be704e92 100644 --- a/error.go +++ b/error.go @@ -564,10 +564,7 @@ func posToLine(pos int, lines []string) (line, col int) { line++ ll := utf8.RuneCountInString(lines[i]) + 1 // +1 for the removed newline if read+ll >= pos { - col = pos - read - if col < 1 { // Should never happen, but just in case. - col = 1 - } + col = max(pos-read, 1) // Should be lower than 1, but just in case. break } read += ll diff --git a/internal/pqtest/ztest.go b/internal/pqtest/ztest.go index 80c443da..d5a8685d 100644 --- a/internal/pqtest/ztest.go +++ b/internal/pqtest/ztest.go @@ -82,10 +82,10 @@ func NormalizeIndent(in string) string { indent++ } - r := "" + var r strings.Builder for _, line := range strings.Split(in, "\n") { - r += strings.Replace(line, "\t", "", indent) + "\n" + r.WriteString(strings.Replace(line, "\t", "", indent) + "\n") } - return strings.TrimSpace(r) + return strings.TrimSpace(r.String()) }