Skip to content

cmd/compile: More helpful error message when trying to call init() #19399

@sean-public

Description

@sean-public

What version of Go are you using (go version)?

1.8

What operating system and processor architecture are you using (go env)?

any

What did you do?

Attempt to call init()

https://play.golang.org/p/enueQhZnFA

What did you expect to see?

An error message indicating that you cannot call init; despite it appearing as a normal function in the source, it is actually a reserved function name that isn't actually declared / callable. To a newcomer who accidentally names a function init, this would be much more insightful.

What did you see instead?

main.go:12: undefined: init

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions