Skip to content

Commit

Permalink
简单升级依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyile committed Dec 3, 2024
1 parent 37d58a6 commit 18a93d8
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 132 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: create-release

on:
push:
branches:
- main # 监听 main 分支的 push 操作(编译和测试/代码检查)
tags:
- 'v*' # 监听以 'v' 开头的标签的 push 操作(发布 Release)

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.23.x"
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

test:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ "1.22.x", "1.23.x" ]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Run test
run: make test COVERAGE_DIR=/tmp/coverage

- name: Send goveralls coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: /tmp/coverage/combined.txt
flag-name: Go-${{ matrix.go }}
parallel: true

check-coverage:
name: Check coverage
needs: [ test ]
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true

# 发布 Release
release:
name: Release a new version
needs: [ lint, test ]
runs-on: ubuntu-latest
# 仅在推送标签时执行
if: ${{ success() && startsWith(github.ref, 'refs/tags/v') }}
steps:
# 1. 检出代码
- name: Checkout code
uses: actions/checkout@v4

# 2. 创建 Release 和上传源码包
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 yangyile-yyle88

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
COVERAGE_DIR ?= .coverage

# cp from: https://github.com/yyle88/sure/blob/10a10cb5c07f6239fc8e310459fb6a240dd117ce/Makefile#L4
test:
@-rm -r $(COVERAGE_DIR)
@mkdir $(COVERAGE_DIR)
make test-with-flags TEST_FLAGS='-v -race -covermode atomic -coverprofile $$(COVERAGE_DIR)/combined.txt -bench=. -benchmem -timeout 20m'

test-with-flags:
@go test $(TEST_FLAGS) ./...
86 changes: 70 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
[![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)
[![GoDoc](https://pkg.go.dev/badge/github.com/yyle88/neatjson)](https://pkg.go.dev/github.com/yyle88/neatjson)
[![Coverage Status](https://img.shields.io/coveralls/github/yyle88/neatjson/master.svg)](https://coveralls.io/github/yyle88/neatjson?branch=main)
![Supported Go Versions](https://img.shields.io/badge/Go-1.22%2C%201.23-lightgrey.svg)
[![GitHub Release](https://img.shields.io/github/release/yyle88/neatjson.svg)](https://github.com/yyle88/neatjson/releases)
[![Go Report Card](https://goreportcard.com/badge/github.com/yyle88/neatjson)](https://goreportcard.com/report/github.com/yyle88/neatjson)

# neatjson
neat json make it neat to use "encoding/json" in golang.

其操作很简单,就是把结构体转json时,传统结果是:
```
{"a": "abc","n": 123}
`neatjson` make it neat to use "encoding/json" in golang.

## CHINESE README

[中文说明](README.zh.md)

## Installation

```bash
go get github.com/yyle88/neatjson
```
这个是转带换行和缩进格式的,便于观察,仅此而已:

## Features

- Convert Go structures to indented JSON strings.
- Format JSON data from raw strings, byte arrays.

## Usage

Here's an example of how to format a Go data structure into a indented JSON string:

```go
package main

import (
"fmt"
"github.com/yyle88/neatjson/neatjsons"
)

func main() {
arg := map[string]any{"a": "abc", "n": 123}
res := neatjsons.S(arg)

fmt.Println(res)
}
```

Output:

```json
{
"a": "abc",
"n": 123
"a": "abc",
"n": 123
}
```
具体使用方法是:
```
go get github.com/yyle88/neatjson
```
在代码中使用时:
```
fmt.Println(neatjsons.S( a ))
```
非常非常的方便。

---

## License

`neatjson` is open-source and released under the MIT License. See the [LICENSE](LICENSE) file for more information.

---

## Support

Welcome to contribute to this project by submitting pull requests or reporting issues.

If you find this package helpful, give it a star on GitHub!

**Thank you for your support!**

**Happy Coding with `neatjson`!** 🎉

Give me stars. Thank you!!!

## See stars
[![see stars](https://starchart.cc/yyle88/neatjson.svg?variant=adaptive)](https://starchart.cc/yyle88/neatjson)
65 changes: 65 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# neatjson

`neatjson` 使得在 Golang 中使用 "encoding/json" 更加简洁和方便。

## 英文文档

[English README](README.md)

## 安装

```bash
go get github.com/yyle88/neatjson
```

## 特性

- 将 Go 结构体转换为带缩进的 JSON 字符串。
- 格式化原始字符串和字节数组中的 JSON 数据。

## 用法

以下是如何将 Go 数据结构格式化为带缩进的 JSON 字符串的示例:

```go
package main

import (
"fmt"
"github.com/yyle88/neatjson/neatjsons"
)

func main() {
arg := map[string]any{"a": "abc", "n": 123}
res := neatjsons.S(arg)

fmt.Println(res)
}
```

输出:

```json
{
"a": "abc",
"n": 123
}
```

---

## 许可

`neatjson` 是一个开源项目,发布于 MIT 许可证下。有关更多信息,请参阅 [LICENSE](LICENSE) 文件。

## 贡献与支持

欢迎通过提交 pull request 或报告问题来贡献此项目。

如果你觉得这个包对你有帮助,请在 GitHub 上给个 ⭐,感谢支持!!!

**感谢你的支持!**

**祝编程愉快!** 🎉

Give me stars. Thank you!!!
11 changes: 7 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ go 1.22.8
require (
github.com/stretchr/testify v1.10.0
github.com/yyle88/erero v1.0.14
github.com/yyle88/runpath v1.0.21
github.com/yyle88/sure v0.0.28
github.com/yyle88/rese v0.0.1
github.com/yyle88/runpath v1.0.22
github.com/yyle88/sure v0.0.31
github.com/yyle88/syntaxgo v0.0.35
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/yyle88/done v1.0.18 // indirect
github.com/yyle88/formatgo v1.0.17 // indirect
github.com/yyle88/formatgo v1.0.19 // indirect
github.com/yyle88/must v0.0.9 // indirect
github.com/yyle88/mutexmap v1.0.8 // indirect
github.com/yyle88/printgo v1.0.1 // indirect
github.com/yyle88/rese v0.0.1 // indirect
github.com/yyle88/tern v0.0.3 // indirect
github.com/yyle88/zaplog v0.0.16 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand Down
15 changes: 9 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
Expand All @@ -16,8 +19,8 @@ github.com/yyle88/done v1.0.18 h1:O71T+76laNmuY1kYP8PHkp6uceoN6ABTng/8c9KpZts=
github.com/yyle88/done v1.0.18/go.mod h1:32UMgjuZP9LctfNNhBQqTyVbjggPOWpoXn8Mp0VrQbw=
github.com/yyle88/erero v1.0.14 h1:ozS3iPLIsnRPSs8AdfbA/3f3hGw5EFkJMkfA/dfI+do=
github.com/yyle88/erero v1.0.14/go.mod h1:NhP5EcPoVlShkMk1cVCFP3im5Zm+JRG35qIInMw7aeo=
github.com/yyle88/formatgo v1.0.17 h1:D+Y+nN2UC09NviEgiMtew80+VfQUsE9cZgBFd3kZXRk=
github.com/yyle88/formatgo v1.0.17/go.mod h1:B0JcneKcVTNjOUTPkg1nnnCemtdukfP7ijiTBVX/ItY=
github.com/yyle88/formatgo v1.0.19 h1:XgcSB8KsGLTnv7UOCVZDtrd3yJggFd2J82xG5qvmdFI=
github.com/yyle88/formatgo v1.0.19/go.mod h1:Q+JpNGVgskW2Xl+BdHXZ7r6y6TQlQOyN7/23Gu/wzoM=
github.com/yyle88/must v0.0.9 h1:LA03i1O4/6Syopma8xqJMiWfAWeehoySeUaRmdQEvKY=
github.com/yyle88/must v0.0.9/go.mod h1:5Ur4BKRx6GuW4gCZNx8Hf+iRS9lVmywSkCpxun/f+Do=
github.com/yyle88/mutexmap v1.0.8 h1:VntAdXID5wbk211LZEPVK96jQBxIcfVIbQuk9cv3P/8=
Expand All @@ -26,10 +29,10 @@ github.com/yyle88/printgo v1.0.1 h1:0lCpq28Tlf0jmYhSIlDQ7A3hAqVYswhBuURLR9xbmsw=
github.com/yyle88/printgo v1.0.1/go.mod h1:yCvpShGBkKdWX5RO+yum2gLbru9ebc04sVmuzhPKSMw=
github.com/yyle88/rese v0.0.1 h1:Eu2I+7BpbkX1n7SOu11AHVqecTuOVdg4becgt2ThGIo=
github.com/yyle88/rese v0.0.1/go.mod h1:GoPiHJPEWyeBL0DxOHT5hLnibFbav+jck/NZxLqNVI8=
github.com/yyle88/runpath v1.0.21 h1:uWi1QrMCU5QUWU1oJJxbmlSCrCwPDRe+tlikV0JbvWM=
github.com/yyle88/runpath v1.0.21/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg=
github.com/yyle88/sure v0.0.28 h1:zVvuVY4Z7cfWkvxEZp1QjbfSTEC2fy/YTlEjSC7Ua0Y=
github.com/yyle88/sure v0.0.28/go.mod h1:C4Mystu7UVdrP658hrxS5jlDE1soh9ZZ1NYJOIVQA6g=
github.com/yyle88/runpath v1.0.22 h1:gcyaNMNZq7yjL2Xlwvs0W7BOkzn4VJTJqA8ko7CKhKg=
github.com/yyle88/runpath v1.0.22/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg=
github.com/yyle88/sure v0.0.31 h1:CBCppn/EtLBGyLBddPOI3GiLOkxexHU/Pj3ohN5aTBQ=
github.com/yyle88/sure v0.0.31/go.mod h1:29eZWpgHwkeK3bq8TL2Db7PP2Zi6JagGJd+gOAjcdjw=
github.com/yyle88/syntaxgo v0.0.35 h1:jcDpBTkVehgaQq3LGOQD/jBFu7eauVn2rqc7qKCqzts=
github.com/yyle88/syntaxgo v0.0.35/go.mod h1:blSLJ3XoI8KWT5FISdBTISi1cHElQxtBzZ2UaeDja9w=
github.com/yyle88/tern v0.0.3 h1:Ut5p1wPAVcreEkmzDp+IiteA3K2vnTeAYE1PyBLNgjU=
Expand Down
Loading

0 comments on commit 18a93d8

Please sign in to comment.