Skip to content
This repository was archived by the owner on May 9, 2021. It is now read-only.
This repository was archived by the owner on May 9, 2021. It is now read-only.

golint asks you to drop else block containing return, even when local vars are being used  #17

@deepakjois

Description

@deepakjois
package main
import (
    "fmt"
)

func main() {
    res := get(3)
    fmt.Println(res)
}

func get(i int) int {
    if f := i * 2; f == 6 {
        return f
    } else {
        return f * 3
    }
}

Running golint displays:

main.go:15:9: if block ends with a return statement, so drop this else and outdent its block

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions