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

Allow ignoring empty structs #114

Open
bkmeneguello opened this issue Oct 23, 2024 · 2 comments
Open

Allow ignoring empty structs #114

bkmeneguello opened this issue Oct 23, 2024 · 2 comments

Comments

@bkmeneguello
Copy link

A common idiom in Go is creating empty structs instead of using other constructs, like:

  • x := Y{}, instead of var x Y
  • x := &Y{}, instead of x := new(Y)

But this linter complains about that. Could be an option to "ignore empty struct initializations"?

@shanee-vanstone-sp
Copy link

Hi Bkmeneguello. I'd really love the same feature too! I had a go at putting together a pull request for it if you want to try it out. #118

@sineemore
Copy link

sineemore commented Dec 18, 2024

Have same request, but for returns with signature (T, bool).

Currently linter checks for (T, error) cases and allows empty structs.
I think it will be beneficial to add same for (T, bool) signatures:

type DivResult struct {
  Result int
}

func Div(a, b int) (X, bool) {
  if b == 0 {
    return X{}, false // <-- error here
  }

  return X{a / b}, true
}

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

3 participants