Skip to content

Unused variable check no enforced for package scope #222

Closed
@gopherbot

Description

@gopherbot

by SRRajesh1989:

A code like:

package main
var strx, inty = "hello", 123
func main() {
}

Note that strx and inty are not used anywhere in the program. But go fail
to report compilation error because of unused variable. But making that
declaration inside the function like below, generates compilation error.

package main
func main() {
var strx, inty = "hello", 123
}

Is this the intended behavior? It will be better to report error in both
the cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions