Skip to content

Commit 18a93d8

Browse files
author
yangyile
committed
简单升级依赖
1 parent 37d58a6 commit 18a93d8

14 files changed

+481
-132
lines changed

.github/workflows/release.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: create-release
2+
3+
on:
4+
push:
5+
branches:
6+
- main # 监听 main 分支的 push 操作(编译和测试/代码检查)
7+
tags:
8+
- 'v*' # 监听以 'v' 开头的标签的 push 操作(发布 Release)
9+
10+
jobs:
11+
lint:
12+
name: lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: "1.23.x"
18+
- uses: actions/checkout@v4
19+
- name: golangci-lint
20+
uses: golangci/golangci-lint-action@v6
21+
with:
22+
version: latest
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
go: [ "1.22.x", "1.23.x" ]
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ matrix.go }}
35+
36+
- name: Run test
37+
run: make test COVERAGE_DIR=/tmp/coverage
38+
39+
- name: Send goveralls coverage
40+
uses: shogo82148/actions-goveralls@v1
41+
with:
42+
path-to-profile: /tmp/coverage/combined.txt
43+
flag-name: Go-${{ matrix.go }}
44+
parallel: true
45+
46+
check-coverage:
47+
name: Check coverage
48+
needs: [ test ]
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: shogo82148/actions-goveralls@v1
52+
with:
53+
parallel-finished: true
54+
55+
# 发布 Release
56+
release:
57+
name: Release a new version
58+
needs: [ lint, test ]
59+
runs-on: ubuntu-latest
60+
# 仅在推送标签时执行
61+
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }}
62+
steps:
63+
# 1. 检出代码
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
67+
# 2. 创建 Release 和上传源码包
68+
- name: Create Release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
generate_release_notes: true
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 yangyile-yyle88
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
COVERAGE_DIR ?= .coverage
2+
3+
# cp from: https://github.com/yyle88/sure/blob/10a10cb5c07f6239fc8e310459fb6a240dd117ce/Makefile#L4
4+
test:
5+
@-rm -r $(COVERAGE_DIR)
6+
@mkdir $(COVERAGE_DIR)
7+
make test-with-flags TEST_FLAGS='-v -race -covermode atomic -coverprofile $$(COVERAGE_DIR)/combined.txt -bench=. -benchmem -timeout 20m'
8+
9+
test-with-flags:
10+
@go test $(TEST_FLAGS) ./...

README.md

+70-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,77 @@
1+
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/yyle88/neatjson/release.yml?branch=main&label=BUILD)](https://github.com/yyle88/neatjson/actions/workflows/release.yml?query=branch%3Amain)
2+
[![GoDoc](https://pkg.go.dev/badge/github.com/yyle88/neatjson)](https://pkg.go.dev/github.com/yyle88/neatjson)
3+
[![Coverage Status](https://img.shields.io/coveralls/github/yyle88/neatjson/master.svg)](https://coveralls.io/github/yyle88/neatjson?branch=main)
4+
![Supported Go Versions](https://img.shields.io/badge/Go-1.22%2C%201.23-lightgrey.svg)
5+
[![GitHub Release](https://img.shields.io/github/release/yyle88/neatjson.svg)](https://github.com/yyle88/neatjson/releases)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/yyle88/neatjson)](https://goreportcard.com/report/github.com/yyle88/neatjson)
7+
18
# neatjson
2-
neat json make it neat to use "encoding/json" in golang.
39

4-
其操作很简单,就是把结构体转json时,传统结果是:
5-
```
6-
{"a": "abc","n": 123}
10+
`neatjson` make it neat to use "encoding/json" in golang.
11+
12+
## CHINESE README
13+
14+
[中文说明](README.zh.md)
15+
16+
## Installation
17+
18+
```bash
19+
go get github.com/yyle88/neatjson
720
```
8-
这个是转带换行和缩进格式的,便于观察,仅此而已:
21+
22+
## Features
23+
24+
- Convert Go structures to indented JSON strings.
25+
- Format JSON data from raw strings, byte arrays.
26+
27+
## Usage
28+
29+
Here's an example of how to format a Go data structure into a indented JSON string:
30+
31+
```go
32+
package main
33+
34+
import (
35+
"fmt"
36+
"github.com/yyle88/neatjson/neatjsons"
37+
)
38+
39+
func main() {
40+
arg := map[string]any{"a": "abc", "n": 123}
41+
res := neatjsons.S(arg)
42+
43+
fmt.Println(res)
44+
}
945
```
46+
47+
Output:
48+
49+
```json
1050
{
11-
"a": "abc",
12-
"n": 123
51+
"a": "abc",
52+
"n": 123
1353
}
1454
```
15-
具体使用方法是:
16-
```
17-
go get github.com/yyle88/neatjson
18-
```
19-
在代码中使用时:
20-
```
21-
fmt.Println(neatjsons.S( a ))
22-
```
23-
非常非常的方便。
55+
56+
---
57+
58+
## License
59+
60+
`neatjson` is open-source and released under the MIT License. See the [LICENSE](LICENSE) file for more information.
61+
62+
---
63+
64+
## Support
65+
66+
Welcome to contribute to this project by submitting pull requests or reporting issues.
67+
68+
If you find this package helpful, give it a star on GitHub!
69+
70+
**Thank you for your support!**
71+
72+
**Happy Coding with `neatjson`!** 🎉
73+
74+
Give me stars. Thank you!!!
75+
76+
## See stars
77+
[![see stars](https://starchart.cc/yyle88/neatjson.svg?variant=adaptive)](https://starchart.cc/yyle88/neatjson)

README.zh.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# neatjson
2+
3+
`neatjson` 使得在 Golang 中使用 "encoding/json" 更加简洁和方便。
4+
5+
## 英文文档
6+
7+
[English README](README.md)
8+
9+
## 安装
10+
11+
```bash
12+
go get github.com/yyle88/neatjson
13+
```
14+
15+
## 特性
16+
17+
- 将 Go 结构体转换为带缩进的 JSON 字符串。
18+
- 格式化原始字符串和字节数组中的 JSON 数据。
19+
20+
## 用法
21+
22+
以下是如何将 Go 数据结构格式化为带缩进的 JSON 字符串的示例:
23+
24+
```go
25+
package main
26+
27+
import (
28+
"fmt"
29+
"github.com/yyle88/neatjson/neatjsons"
30+
)
31+
32+
func main() {
33+
arg := map[string]any{"a": "abc", "n": 123}
34+
res := neatjsons.S(arg)
35+
36+
fmt.Println(res)
37+
}
38+
```
39+
40+
输出:
41+
42+
```json
43+
{
44+
"a": "abc",
45+
"n": 123
46+
}
47+
```
48+
49+
---
50+
51+
## 许可
52+
53+
`neatjson` 是一个开源项目,发布于 MIT 许可证下。有关更多信息,请参阅 [LICENSE](LICENSE) 文件。
54+
55+
## 贡献与支持
56+
57+
欢迎通过提交 pull request 或报告问题来贡献此项目。
58+
59+
如果你觉得这个包对你有帮助,请在 GitHub 上给个 ⭐,感谢支持!!!
60+
61+
**感谢你的支持!**
62+
63+
**祝编程愉快!** 🎉
64+
65+
Give me stars. Thank you!!!

go.mod

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ go 1.22.8
55
require (
66
github.com/stretchr/testify v1.10.0
77
github.com/yyle88/erero v1.0.14
8-
github.com/yyle88/runpath v1.0.21
9-
github.com/yyle88/sure v0.0.28
8+
github.com/yyle88/rese v0.0.1
9+
github.com/yyle88/runpath v1.0.22
10+
github.com/yyle88/sure v0.0.31
1011
github.com/yyle88/syntaxgo v0.0.35
1112
)
1213

1314
require (
1415
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
16+
github.com/kr/pretty v0.3.1 // indirect
17+
github.com/kr/text v0.2.0 // indirect
1518
github.com/pkg/errors v0.9.1 // indirect
1619
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
20+
github.com/rogpeppe/go-internal v1.13.1 // indirect
1721
github.com/yyle88/done v1.0.18 // indirect
18-
github.com/yyle88/formatgo v1.0.17 // indirect
22+
github.com/yyle88/formatgo v1.0.19 // indirect
1923
github.com/yyle88/must v0.0.9 // indirect
2024
github.com/yyle88/mutexmap v1.0.8 // indirect
2125
github.com/yyle88/printgo v1.0.1 // indirect
22-
github.com/yyle88/rese v0.0.1 // indirect
2326
github.com/yyle88/tern v0.0.3 // indirect
2427
github.com/yyle88/zaplog v0.0.16 // indirect
2528
go.uber.org/multierr v1.11.0 // indirect

go.sum

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
12
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
23
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
34
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
45
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
56
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
67
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
8+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
79
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
810
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
911
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
1012
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
1114
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
1215
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
1316
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
@@ -16,8 +19,8 @@ github.com/yyle88/done v1.0.18 h1:O71T+76laNmuY1kYP8PHkp6uceoN6ABTng/8c9KpZts=
1619
github.com/yyle88/done v1.0.18/go.mod h1:32UMgjuZP9LctfNNhBQqTyVbjggPOWpoXn8Mp0VrQbw=
1720
github.com/yyle88/erero v1.0.14 h1:ozS3iPLIsnRPSs8AdfbA/3f3hGw5EFkJMkfA/dfI+do=
1821
github.com/yyle88/erero v1.0.14/go.mod h1:NhP5EcPoVlShkMk1cVCFP3im5Zm+JRG35qIInMw7aeo=
19-
github.com/yyle88/formatgo v1.0.17 h1:D+Y+nN2UC09NviEgiMtew80+VfQUsE9cZgBFd3kZXRk=
20-
github.com/yyle88/formatgo v1.0.17/go.mod h1:B0JcneKcVTNjOUTPkg1nnnCemtdukfP7ijiTBVX/ItY=
22+
github.com/yyle88/formatgo v1.0.19 h1:XgcSB8KsGLTnv7UOCVZDtrd3yJggFd2J82xG5qvmdFI=
23+
github.com/yyle88/formatgo v1.0.19/go.mod h1:Q+JpNGVgskW2Xl+BdHXZ7r6y6TQlQOyN7/23Gu/wzoM=
2124
github.com/yyle88/must v0.0.9 h1:LA03i1O4/6Syopma8xqJMiWfAWeehoySeUaRmdQEvKY=
2225
github.com/yyle88/must v0.0.9/go.mod h1:5Ur4BKRx6GuW4gCZNx8Hf+iRS9lVmywSkCpxun/f+Do=
2326
github.com/yyle88/mutexmap v1.0.8 h1:VntAdXID5wbk211LZEPVK96jQBxIcfVIbQuk9cv3P/8=
@@ -26,10 +29,10 @@ github.com/yyle88/printgo v1.0.1 h1:0lCpq28Tlf0jmYhSIlDQ7A3hAqVYswhBuURLR9xbmsw=
2629
github.com/yyle88/printgo v1.0.1/go.mod h1:yCvpShGBkKdWX5RO+yum2gLbru9ebc04sVmuzhPKSMw=
2730
github.com/yyle88/rese v0.0.1 h1:Eu2I+7BpbkX1n7SOu11AHVqecTuOVdg4becgt2ThGIo=
2831
github.com/yyle88/rese v0.0.1/go.mod h1:GoPiHJPEWyeBL0DxOHT5hLnibFbav+jck/NZxLqNVI8=
29-
github.com/yyle88/runpath v1.0.21 h1:uWi1QrMCU5QUWU1oJJxbmlSCrCwPDRe+tlikV0JbvWM=
30-
github.com/yyle88/runpath v1.0.21/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg=
31-
github.com/yyle88/sure v0.0.28 h1:zVvuVY4Z7cfWkvxEZp1QjbfSTEC2fy/YTlEjSC7Ua0Y=
32-
github.com/yyle88/sure v0.0.28/go.mod h1:C4Mystu7UVdrP658hrxS5jlDE1soh9ZZ1NYJOIVQA6g=
32+
github.com/yyle88/runpath v1.0.22 h1:gcyaNMNZq7yjL2Xlwvs0W7BOkzn4VJTJqA8ko7CKhKg=
33+
github.com/yyle88/runpath v1.0.22/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg=
34+
github.com/yyle88/sure v0.0.31 h1:CBCppn/EtLBGyLBddPOI3GiLOkxexHU/Pj3ohN5aTBQ=
35+
github.com/yyle88/sure v0.0.31/go.mod h1:29eZWpgHwkeK3bq8TL2Db7PP2Zi6JagGJd+gOAjcdjw=
3336
github.com/yyle88/syntaxgo v0.0.35 h1:jcDpBTkVehgaQq3LGOQD/jBFu7eauVn2rqc7qKCqzts=
3437
github.com/yyle88/syntaxgo v0.0.35/go.mod h1:blSLJ3XoI8KWT5FISdBTISi1cHElQxtBzZ2UaeDja9w=
3538
github.com/yyle88/tern v0.0.3 h1:Ut5p1wPAVcreEkmzDp+IiteA3K2vnTeAYE1PyBLNgjU=

0 commit comments

Comments
 (0)