-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix: #267 #306
Merged
Merged
fix: #267 #306
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
26271d1
feat: add environment helper
devhaozi d57ffab
feat: optimize sonic
devhaozi 940e36d
fix: tests
devhaozi 199e880
feat: rename to env
devhaozi 314cf77
feat: optimize json
devhaozi 812e38b
fix: optimize tests
devhaozi 6363cc9
feat: add doc for methods
devhaozi c228474
feat: only build sonic on x86
devhaozi 7d66f5c
Merge branch 'master' into haozi/sonic
devhaozi 39850d0
fix: sonic to json
devhaozi 4cb12a7
fix: lint
devhaozi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package carbon | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/bytedance/sonic" | ||
"github.com/stretchr/testify/assert" | ||
Comment on lines
+4
to
8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems test file not need import sonic for performance. |
||
) | ||
|
||
|
@@ -44,7 +44,7 @@ func TestMarshalJSON(t *testing.T) { | |
CreatedAt3: TimestampMicro{Parse("2025-08-05 13:14:15.999999")}, | ||
CreatedAt4: TimestampNano{Parse("2025-08-05 13:14:15.999999999")}, | ||
} | ||
data, err := sonic.Marshal(&person) | ||
data, err := json.Marshal(&person) | ||
assert.Nil(t, err) | ||
fmt.Printf("Person output by json:\n%s\n", data) | ||
} | ||
|
@@ -67,7 +67,7 @@ func TestUnmarshalJSON(t *testing.T) { | |
"created_at4": 1596604455999999999 | ||
}` | ||
|
||
err := sonic.Unmarshal([]byte(str), &person) | ||
err := json.Unmarshal([]byte(str), &person) | ||
assert.Nil(t, err) | ||
fmt.Printf("Json string parse to person:\n%+v\n", person) | ||
} | ||
|
@@ -89,7 +89,7 @@ func TestErrorJson(t *testing.T) { | |
"created_at3": 0, | ||
"created_at4": 0 | ||
}` | ||
err := sonic.Unmarshal([]byte(str), &person) | ||
err := json.Unmarshal([]byte(str), &person) | ||
assert.NotNil(t, err) | ||
fmt.Printf("Json string parse to person:\n%+v\n", person) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package env | ||
|
||
import "runtime" | ||
|
||
// IsWindows returns whether the current operating system is Windows. | ||
// IsWindows 返回当前操作系统是否为 Windows。 | ||
func IsWindows() bool { | ||
return runtime.GOOS == "windows" | ||
} | ||
|
||
// IsLinux returns whether the current operating system is Linux. | ||
// IsLinux 返回当前操作系统是否为 Linux。 | ||
func IsLinux() bool { | ||
return runtime.GOOS == "linux" | ||
} | ||
|
||
// IsDarwin returns whether the current operating system is Darwin. | ||
// IsDarwin 返回当前操作系统是否为 Darwin。 | ||
func IsDarwin() bool { | ||
return runtime.GOOS == "darwin" | ||
} | ||
|
||
// IsArm returns whether the current CPU architecture is ARM. | ||
// IsArm 返回当前 CPU 架构是否为 ARM。 | ||
func IsArm() bool { | ||
return runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" | ||
} | ||
|
||
// IsX86 returns whether the current CPU architecture is X86. | ||
// IsX86 返回当前 CPU 架构是否为 X86。 | ||
func IsX86() bool { | ||
return runtime.GOARCH == "386" || runtime.GOARCH == "amd64" | ||
} | ||
|
||
// Is64Bit returns whether the current CPU architecture is 64-bit. | ||
// Is64Bit 返回当前 CPU 架构是否为 64 位。 | ||
func Is64Bit() bool { | ||
return runtime.GOARCH == "amd64" || runtime.GOARCH == "arm64" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kkumar-gcc You can use this method in your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay