Skip to content

proposal: cmd/godoc: treat function returning slice as constructor #18063

Closed
@mvdan

Description

@mvdan

This is sort of a follow-up to #14004. Sometimes, there are constructors that return a slice of a type. For example:

https://golang.org/pkg/net/mail/#pkg-index

func ParseAddressList(list string) ([]*Address, error)
type Address
    func ParseAddress(address string) (*Address, error)
    func (a *Address) String() string

go/doc does not consider ParseAddressList an Address type func as it returns a slice, not the type directly. Since this rule is reserved for the first returned type, I suggest this is relaxed to also allow slices (and perhaps arrays too? but couldn't find an example of that).

CC @aclements @robpike

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions