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

proposal: go/types: add HasTypeName interface #66890

adonovan opened this issue Apr 18, 2024 · 0 comments

proposal: go/types: add HasTypeName interface #66890

adonovan opened this issue Apr 18, 2024 · 0 comments


Copy link

During the types.Alias work, there was a recurring need (7 times in x/tools; @findleyr is adding an eighth) for this interface:

package types // import "go/types"

// HasTypeName abstracts the three kinds of types that have declared names:
// aliases ([*Alias]), defined types ([*Named]), and type parameters ([*TypeParam]).
// Note that the Go spec considers built-in types such as string and int to
// be defined types, but this package represents them as [*Basic],
// since they do not have a declaration or [TypeName].
type HasTypeName interface {
    Obj() *TypeName

Of course users can easily define it for themselves, but adding it to go/types provides a good place to hang additional documentation.


@findleyr @griesemer

@gopherbot gopherbot added this to the Proposal milestone Apr 18, 2024
@adonovan adonovan self-assigned this Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Status: Incoming

No branches or pull requests

2 participants