Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Go1.21.0 #493

Merged
merged 18 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/benchmark-linux-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:

- uses: actions/checkout@v2

- name: Check Branch
run: ./check_branch_name.sh ${{ github.head_ref }}

- name: Set up Go
uses: actions/setup-go@v2
with:
Expand All @@ -27,4 +24,4 @@ jobs:
${{ runner.os }}-go-

- name: Benchmark sonic
run: sh bench-arm.sh
run: sh scripts/bench-arm.sh
5 changes: 1 addition & 4 deletions .github/workflows/benchmark-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:

- uses: actions/checkout@v2

- name: Check Branch
run: ./check_branch_name.sh ${{ github.head_ref }}

- name: Set up Go
uses: actions/setup-go@v2
with:
Expand All @@ -27,4 +24,4 @@ jobs:
${{ runner.os }}-go-

- name: Benchmark sonic
run: sh bench.sh
run: sh scripts/bench.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push Check Windows-X64
name: Compatibility Test Windows-X64

on: pull_request

Expand All @@ -23,5 +23,18 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- name: Compatibility Test
run: go test -v .
- name: main
run: |
set GOMAXPROCS=4
go test -v -race github.com/bytedance/sonic

- name: ast
run: |
set GOMAXPROCS=4
go test -v -race github.com/bytedance/sonic/ast

- name: external
run: |
cd ./external_jsonlib_test
set GOMAXPROCS=4
go test -v -race ./...
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Push Check Linux-ARM
name: Compatibility Test Linux-X64|ARM

on: pull_request

jobs:
build:
strategy:
matrix:
go-version: [1.15.x, 1.16.x, 1.20.x]
os: [arm]
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
os: [arm, X64]
runs-on: ${{ matrix.os }}
steps:
- name: Clear repository
Expand All @@ -27,8 +27,11 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- name: Compatibility Test - main
- name: main
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic

- name: Compatibility Test - ast
- name: ast
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/ast

- name: qemu
run: sh scripts/qemu.sh
5 changes: 1 addition & 4 deletions .github/workflows/fuzzing-linux-x64.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Fuzz Linux-X64
name: Fuzz Test Linux-X64

on: pull_request

Expand All @@ -11,9 +11,6 @@ jobs:

- uses: actions/checkout@v2

- name: Check Branch
run: ./check_branch_name.sh ${{ github.head_ref }}

- name: Set up Go
uses: actions/setup-go@v2
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push Check Go1.18-Linux-X64
name: Generic Test Go1.18-Linux-X64

on: pull_request

Expand All @@ -23,10 +23,5 @@ jobs:
restore-keys: |
${{ runner.os }}-go-

- name: Unit Test
run: |
GOMAXPROCS=4 go test -v -race ./...
GOMAXPROCS=4 go test -v -race ./external_jsonlib_test/...

- name: Generic Test
run: GOMAXPROCS=4 go test -v -race ./generic_test
28 changes: 28 additions & 0 deletions .github/workflows/go_latest_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Unit Test Go-Latest-Linux-X64

on: push

jobs:
build:
runs-on: [self-hosted, X64]
steps:
- name: Clear repository
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE

- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.6

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: script
run: |
sh ./scripts/go_latest.sh go1.21.0
3 changes: 3 additions & 0 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ jobs:
uses: apache/skywalking-eyes/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check Branch
run: ./scripts/check_branch_name.sh ${{ github.head_ref }}
36 changes: 0 additions & 36 deletions .github/workflows/push-check-qemu.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Push Check Linux-X64
name: Unit Test Linux-X64

on: pull_request
on: push

jobs:
build:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.19.x, 1.20.x]
go-version: [1.16.x, 1.17.x, 1.18.x, 1.19.x, 1.20.x]
runs-on: [self-hosted, X64]
steps:
- name: Clear repository
Expand All @@ -31,8 +31,11 @@ jobs:
- name: Unit Test
run: |
go test -race -covermode=atomic -coverprofile=coverage.txt ./...
cd ./external_jsonlib_test
go test -v ./...

- name: external
run: |
cd ./external_jsonlib_test
GOMAXPROCS=4 go test -v -race ./...

- name: Codecov
run: bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion ast/api_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2022 ByteDance Inc.
Expand Down
3 changes: 1 addition & 2 deletions ast/api_amd64_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build amd64 && go1.16 && !go1.21
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2022 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion ast/api_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.21
// +build !amd64 !go1.16 go1.22

/*
* Copyright 2022 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.21
// +build !amd64 !go1.16 go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decode_float_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decoder/decoder_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2023 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion decoder/decoder_amd64_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
29 changes: 3 additions & 26 deletions decoder/decoder_compat.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !amd64 || !go1.16 || go1.21
// +build !amd64 !go1.16 go1.21
// +build !amd64 !go1.16 go1.22

/*
* Copyright 2023 ByteDance Inc.
Expand Down Expand Up @@ -170,35 +169,13 @@ func Pretouch(vt reflect.Type, opts ...option.CompileOption) error {
return nil
}

type StreamDecoder struct {
r io.Reader
buf []byte
scanp int
scanned int64
err error
Decoder
}
type StreamDecoder = json.Decoder

// NewStreamDecoder adapts to encoding/json.NewDecoder API.
//
// NewStreamDecoder returns a new decoder that reads from r.
func NewStreamDecoder(r io.Reader) *StreamDecoder {
return &StreamDecoder{r : r}
}

// Decode decodes input stream into val with corresponding data.
// Redundantly bytes may be read and left in its buffer, and can be used at next call.
// Either io error from underlying io.Reader (except io.EOF)
// or syntax error from data will be recorded and stop subsequently decoding.
func (self *StreamDecoder) Decode(val interface{}) (err error) {
dec := json.NewDecoder(self.r)
if (self.f | uint64(OptionUseNumber)) != 0 {
dec.UseNumber()
}
if (self.f | uint64(OptionDisableUnknown)) != 0 {
dec.DisallowUnknownFields()
}
return dec.Decode(val)
return json.NewDecoder(r)
}

// SyntaxError represents json syntax error
Expand Down
2 changes: 1 addition & 1 deletion encode_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_amd64.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2023 ByteDance Inc.
Expand Down
2 changes: 1 addition & 1 deletion encoder/encoder_amd64_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build amd64,go1.16,!go1.21
// +build amd64,go1.16,!go1.22

/*
* Copyright 2021 ByteDance Inc.
Expand Down
17 changes: 3 additions & 14 deletions encoder/encoder_compat.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !amd64 !go1.16 go1.21
// +build !amd64 !go1.16 go1.22

/*
* Copyright 2023 ByteDance Inc.
Expand Down Expand Up @@ -216,23 +216,12 @@ func Valid(data []byte) (ok bool, start int) {
}

// StreamEncoder uses io.Writer as
type StreamEncoder struct {
w io.Writer
Encoder
}
type StreamEncoder = json.Encoder

// NewStreamEncoder adapts to encoding/json.NewDecoder API.
//
// NewStreamEncoder returns a new encoder that write to w.
func NewStreamEncoder(w io.Writer) *StreamEncoder {
return &StreamEncoder{w: w}
return json.NewEncoder(w)
}

// Encode encodes interface{} as JSON to io.Writer
func (enc *StreamEncoder) Encode(val interface{}) (err error) {
jenc := json.NewEncoder(enc.w)
jenc.SetEscapeHTML((enc.Opts & EscapeHTML) != 0)
jenc.SetIndent(enc.prefix, enc.indent)
err = jenc.Encode(val)
return err
}
Loading
Loading