Go

Go

Made by DeepSource

Unnecessary block CRT-A0008

Anti-pattern
Minor
Autofix

It is not recommended to use unnecessary blocks.

Blocks aren't necessary unless scopes need to be separated. If a scope is using values solely from the parent scope, it isn't needed.

Bad practice

var err error
{
    err = fmt.Errorf("some error occurred")
}

Recommended

err := fmt.Errorf("some error occurred")

Bad practice

x := 1
{
    x += 4
}

Recommended

x := 1
x += 4