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.

Warn if defer calls a function returning a closure if there is no trailing () #451

@larytet

Description

@larytet

For example

package main

import "fmt"

func GetClosure() func() {
	fmt.Println("0")
	return func() {
		fmt.Println("1")
	}
}

func main() {
	defer GetClosure() // Oops: should be defer GetClosure()()
	fmt.Println("2")
}

https://play.golang.org/p/XPiGZaUPNh8
I tried https://github.com/kisielk/errcheck/ - it does not warn either.

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