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

Please don't use json tag in config, use zero tag to replace json tag #4438

Open
studyzy opened this issue Oct 24, 2024 · 1 comment
Open

Comments

@studyzy
Copy link

studyzy commented Oct 24, 2024

Is your feature request related to a problem? Please describe.
In config document, user use json tag like this:

type Config struct {
    Name string // 没有任何 tag,表示配置必填
    Port int64 `json:",default=8080"` // 如果配置中没有配置,将会初始成 8080
    Path string `json:",optional"`
}

but golangci-lint show error:

SA5008: unknown JSON option "default=8080" (staticcheck)
 SA5008: unknown JSON option "optional" (staticcheck)

Describe the solution you'd like
Use your own tag, don't use json tag.
for example:

type Config struct {
    Name string // 没有任何 tag,表示配置必填
    Port int64 `zero:"default=8080"` // 如果配置中没有配置,将会初始成 8080
    Path string `zero:"optional"`
}
@kesonan
Copy link
Collaborator

kesonan commented Nov 30, 2024

This requirement is very personalized and is not supported. Have you tried the //nolint:all comment to ignore the lint of the modified structure?

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

No branches or pull requests

2 participants