Skip to content

proposal: spec: permit goto over declaration if variable is not used after goto label #26058

Description

@pjebs

Right now you get this error: goto SKIP jumps over declaration of queryArgs

if len(s.standardDays) == 0 {
goto SKIP
}

queryArgs := []interface{}{}
//Do stuff with queryArgs

SKIP:
//Do stuff here BUT queryArgs is not used ANYWHERE from SKIP onwards

Currently I have to refactor all my code like this (including placing var err error at the top):

var queryArgs []interface{}

if len(s.standardDays) == 0 {
goto SKIP
}

queryArgs = []interface{}{}
//Do stuff with queryArgs

SKIP:
//Do stuff here BUT queryArgs is not used ANYWHERE from SKIP onwards

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions