Skip to content

unexported-return: unexported interfaces should not be allowed #1457

@tie

Description

@tie

Currently, unexported-return rule allows returning unexported interface types. E.g.

type unexportedInterface interface {
        unexportedMethod()
}

func New() unexportedInterface {
        return nil
}

As per discussion in #1456 (comment), this is unfriendly to the user of the package. The example above is also “annoying to use“ because the interface type includes an unexported method, so it cannot be assigned to a value that is a subset of the original interface in different package. E.g. https://go.dev/play/p/ohypfiXhADR

Expected behavior

The unexported-return rule should not allow named unexported return types (except when defined as an exported type alias).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions