Skip to content

Commit

Permalink
fix go 1.21 linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
devsergiy committed Aug 22, 2024
1 parent c2ada13 commit 074634c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions parser_timing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package astjson
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
)
Expand Down Expand Up @@ -183,7 +183,7 @@ var (
)

func getFromFile(filename string) string {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
panic(fmt.Errorf("cannot read %s: %s", filename, err))
}
Expand Down
8 changes: 1 addition & 7 deletions util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package astjson

import (
"reflect"
"unsafe"
)

Expand All @@ -10,12 +9,7 @@ func b2s(b []byte) string {
}

func s2b(s string) (b []byte) {
strh := (*reflect.StringHeader)(unsafe.Pointer(&s))
sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
sh.Data = strh.Data
sh.Len = strh.Len
sh.Cap = strh.Len
return b
return unsafe.Slice(unsafe.StringData(s), len(s))
}

const maxStartEndStringLen = 80
Expand Down

0 comments on commit 074634c

Please sign in to comment.