Skip to content

Commit fc58ff7

Browse files
committed
Don't support Go older than 1.20
1 parent 5136601 commit fc58ff7

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
go: ['1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20', '1.21']
14+
go: ['1.20', '1.21']
1515
os: ['ubuntu-latest', 'windows-latest']
1616
include:
1717
- go: 1.16 # Oldest Go version still tested (Windows requires 1.20+ due to https://github.com/golang/go/issues/57455)

parser/string_to_bytes.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
//go:build !go1.20
2-
// +build !go1.20
1+
//go:build go1.20
2+
// +build go1.20
33

44
package parser
55

6-
import (
7-
"reflect"
8-
"unsafe"
9-
)
6+
import "unsafe"
107

118
func toBytes(s string) (b []byte) {
12-
pb := (*reflect.SliceHeader)(unsafe.Pointer(&b))
13-
ps := (*reflect.StringHeader)(unsafe.Pointer(&s))
14-
pb.Data = ps.Data
15-
pb.Len = ps.Len
16-
pb.Cap = ps.Len
17-
18-
return b
9+
if s == "" {
10+
return nil
11+
}
12+
13+
return unsafe.Slice(unsafe.StringData(s), len(s))
1914
}

parser/string_to_bytes_go1.20.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)