1 Star 0 Fork 0

soluty/goon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

goon

Build Status GoDoc

本库修改自https://github.com/shurcooL/goon, 由于上面的库常久不更新, 并且我需要做一些小的修改满足需求, 所以fork了自用, 仍采用MIT许可.

主要修改有:

  1. 增加goon="-"的tag让我们可以对结构体手动控制哪些字段不需要
  2. 对XXX_开头的字段全都去掉, 这些是protobuf中比较多余的字段
  3. 对golang特有的枚举做支持

Package goon is a deep pretty printer with Go-like notation. It implements the goon specification.

Installation

go get -u github.com/shurcooL/go-goon

Examples

x := Lang{
	Name: "Go",
	Year: 2009,
	URL:  "http",
	Inner: &Inner{
		Field1: "Secret!",
	},
}

goon.Dump(x)

// Output:
// (Lang)(Lang{
// 	Name: (string)("Go"),
// 	Year: (int)(2009),
// 	URL:  (string)("http"),
// 	Inner: (*Inner)(&Inner{
// 		Field1: (string)("Secret!"),
// 		Field2: (int)(0),
// 	}),
// })
items := []int{1, 2, 3}

goon.DumpExpr(len(items))

// Output:
// len(items) = (int)(3)
adderFunc := func(a int, b int) int {
	c := a + b
	return c
}

goon.DumpExpr(adderFunc)

// Output:
// adderFunc = (func(int, int) int)(func(a int, b int) int {
// 	c := a + b
// 	return c
// })

Directories

Path Synopsis
bypass Package bypass allows bypassing reflect restrictions on accessing unexported struct fields.

Attribution

go-goon source was based on the existing source of go-spew by Dave Collins.

License

MIT License Copyright (c) 2021 soluty 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.

简介

源自https://github.com/shurcooL/go-goon, 由于该库长久不更新, 并且自己有一些特殊的需求, 所以拷贝了源码在其基础上修改. 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/soluty/goon.git
git@gitee.com:soluty/goon.git
soluty
goon
goon
master

搜索帮助