An exported function returns a value of an unexported type
What it finds
func NewClient() *client: callers outside the package get a value whose type they cannot name, so they cannot declare a variable of it, store it in a field or write a function that takes it, and its documentation does not show up with the package's. Returning an exported type or an interface avoids that.
Reported are results of exported functions whose type is a type declared in the file with an unexported name, or a pointer to one.
From the rule's source, exported_returns_unexported.rs.
package p type client struct{} type Client struct{} func NewClient() *client {tx0 reports: callers cannot name the type client return &client{}} func New() *Client { return &Client{}} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:exported-returns-unexported" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:exported-returns-unexported] reason="..."tx0 explain tx0/go:exported-returns-unexported shows the same in the terminal. Found a false positive? Report it.