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

Bug fix: omitempty关键字,给它赋的值恰好等于默认空值的话,在转为 json 之后也不会输出这个 field #539

Merged
merged 1 commit into from Feb 28, 2022

Conversation

lyj0309
Copy link
Contributor

@lyj0309 lyj0309 commented Feb 27, 2022

CheckPath 这个字段默认是false,就算赋值了,只有true才能被json解析,这个是“omitempty” 关键字的

LineColor这个字段也是,如果直接给Color结构体,就算注明omitempty关键字也无用,需要指针,这样 Golang 就能知道一个指针的“空值”是多少了,否则面对一个我们自定义的结构, Golang 是猜不出我们想要的空值的

详情
https://www.jianshu.com/p/a2ed0d23d1b0

@silenceper silenceper merged commit 1b5c5fb into silenceper:v2 Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants