Skip to content

Commit

Permalink
chore: update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Mar 6, 2025
1 parent 578d9a3 commit 62e2c49
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ A blazingly fast JSON serializing & deserializing library, accelerated by JI

## Requirement

- Go: 1.17~1.23
- Go: 1.17~1.24
- OS: Linux / MacOS / Windows
- CPU: AMD64 / ARM64(need go1.20 above)
- CPU: AMD64 / (ARM64, need go1.20 above)

## Features

Expand Down
4 changes: 2 additions & 2 deletions README_ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

## 依赖

- Go: 1.17~1.23
- Go: 1.17~1.24
- OS: Linux / MacOS / Windows
- CPU: AMD64 / ARM64需要 Go1.20 以上)
- CPU: AMD64 / (ARM64, 需要 Go1.20 以上)

## 接口

Expand Down
5 changes: 2 additions & 3 deletions ast/api_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ package ast

import (
`encoding/json`
`fmt`
`os`
`unicode/utf8`

`github.com/bytedance/sonic/internal/native/types`
`github.com/bytedance/sonic/internal/rt`
`github.com/bytedance/sonic/internal/compat`
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING:(ast) sonic only supports go1.17~1.23, but your environment is not suitable")
compat.Warn("sonic/ast")
}

func quote(buf *[]byte, val string) {
Expand Down
5 changes: 2 additions & 3 deletions decoder/decoder_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ package decoder
import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"reflect"
"unsafe"

"github.com/bytedance/sonic/internal/decoder/consts"
"github.com/bytedance/sonic/internal/native/types"
"github.com/bytedance/sonic/option"
"github.com/bytedance/sonic/internal/compat"
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING: sonic/decoder only supports (Go1.17~1.23 && CPU amd64) or (go1.20~1.23 && CPU arm64), but your environment is not suitable")
compat.Warn("sonic/decoder")
}

const (
Expand Down
5 changes: 2 additions & 3 deletions encoder/encoder_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ package encoder

import (
`io`
`fmt`
`os`
`bytes`
`encoding/json`
`reflect`

`github.com/bytedance/sonic/option`
`github.com/bytedance/sonic/internal/compat`
)

func init() {
fmt.Fprintln(os.Stderr, "WARNING:(encoder) sonic only supports (Go1.17~1.23 && CPU amd64) or (G01.20~1.23 && CPU arm64) , but your environment is not suitable")
compat.Warn("sonic/encoder")
}

// EnableFallback indicates if encoder use fallback
Expand Down
12 changes: 12 additions & 0 deletions internal/compat/warn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build !amd64,!arm64 go1.25 !go1.17 arm64,!go1.20

package compat

import (
"fmt"
"os"
)

func Warn(prefix string) {
fmt.Fprintf(os.Stderr, "WARNING: %s only supports (go1.17~1.24 && amd64 CPU) or (go1.20~1.24 && CPU arm64 CPU), but your environment is not suitable and will fallback to encoding/json\n", prefix)
}

0 comments on commit 62e2c49

Please sign in to comment.