Go

Go

By DeepSource

Hidden goroutine GO-E1007

Bug risk
Critical

Function invocations are expected to be synchronous, but this function will execute asynchronously because every instruction of the function is executed in a goroutine. Instead, it is recommended to remove the internal goroutine and call the function using 'go'.

Bad practice

func hello() {
    go func() {
        fmt.Println("hello world")
    }()
}

func world() {
    hello()
    ...
}

Recommended

func hello() {
    fmt.Println("hello world")
}

func world() {
    go hello()
    ...
}