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

ignoreCase: private structs with single interface #31

Open
cardil opened this issue Nov 10, 2021 · 6 comments
Open

ignoreCase: private structs with single interface #31

cardil opened this issue Nov 10, 2021 · 6 comments

Comments

@cardil
Copy link

cardil commented Nov 10, 2021

Returning private structs, as this linter advises, is cumbersome to the caller. They are private for a reason, so a caller should be interested only in behavior (interface).

Linter should allow returning public interface instead of private type with single interface.

Also, worth adding that returning private structs is considered an error by revive linter.

Implementing this will likely resolve #21

@butuzov
Copy link
Owner

butuzov commented Nov 10, 2021

Make sense to me. I will implement this check soon.

P/S/
The only case when it doesn't its internal usage (the interface used locally within the package ).

@nawa
Copy link

nawa commented Dec 3, 2021

This should be controlled by a flag

I use this feature returning a private struct and use its interface on the client side. It is common approach when you declare interfaces on the client side

client.go

package client

import "impl"

type IFace interface {
    Do()
}

instance := impl.New()

impl.go

package impl



type privateImpl struct {
}

func (*privateImpl) Do() {
}

func New() *privateImpl {
  return &privateImpl{}
}

@butuzov
Copy link
Owner

butuzov commented Dec 3, 2021

@nava do you use this linter as it is or a part of golangci-lint ?

@nawa
Copy link

nawa commented Dec 3, 2021

@nava do you use this linter as it is or a part of golangci-lint ?

Yes, of course

@butuzov
Copy link
Owner

butuzov commented Dec 4, 2021

Сергей, вы не поняли мой вопрос: вы используете ireturn в стендалон режиме (как отдельную бинарную программу илиже в составе golangci-lint?

@nawa
Copy link

nawa commented Dec 4, 2021

Я все правильно понял - "да, конечно" в составе golangci-lint

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