Skip to content

go/types: improve error messages by using compact package names #41044

@emil14

Description

@emil14

What I'm going to talk about is probably related to Go compiler or something else at the lower level that VSCode, but I'm not sure. It would be great if someone could answer me and maybe move this issue to project where it should be.

Today I saw this message (from my working project):

cannot use &(controller literal) (value of type *controller) as apiaccess.Controller value in return statement:
wrong type for method GetAvailableServices
(have func(ctx context.Context, p gitlab.somecompany.net/project/internal/apiaccess.GetAvailableServicesParams) ([]gitlab.somecompany.net/project/internal/service.Service, error),
want func(ctx context.Context, p gitlab.somecompany.net/project/internal/apiaccess.GetAvailableServicesParams) (*[]gitlab.somecompany.net/project/internal/service.Service, error))

It's a lot :) And it's hard to read. While the actual information is just "missing * symbol in return statement"

First of all we could get rid of these long paths to variables which in my example starts with gitlab.somecompany.net/project. Maybe we can even drop all of the paths and write apiaccess.GetAvailableServicesParams vs gitlab.somecompany.net/project/internal/apiaccess.GetAvailableServicesParams. This is how it could look like:

cannot use &(controller literal) (value of type *controller) as apiaccess.Controller in return statement:
wrong type for method GetAvailableServices
(have func(ctx context.Context, p apiaccess.GetAvailableServicesParams) ([]service.Service, error),
want func(ctx context.Context, p apiaccess.GetAvailableServicesParams) (*[]service.Service, error))

Maybe we could drop paths only for current project (using the "module" value in go.mod)

And lastly I would like to share the perfect error message :) I know it's hard to implement and it's hardly relevant to VSCode but anyway

cannot use *controller as apiaccess.Controller in return statement:
wrong type for method GetAvailableServices ([]service.Service instead of *[]service.Service in return)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions