DEV Community 👩‍💻👨‍💻

official_dulin
official_dulin

Posted on

Is there any place I can let others review my Go code?

Especially concurrency-related code, because they are difficult to test, although you can use go test -race command to detect race condition.

Besides, how to ensure that the goroutine does not leak memory and has the best performance.

Code review generally requires people with more relevant experience, so it seems to be more difficult than solving program problems.

It may take a lot of time for code reviewers. Time is precious. Therefore, without any incentives, I am not sure that my code can be reviewed in time by others and provide good suggestions.

A simple example:

package main

import (
    "fmt"
    "time"
)

func main() {
    var x = 123

    go func() {
        x = 789 // write to x
    }()

    time.Sleep(time.Second)
    fmt.Println(x) // read from x
}
Enter fullscreen mode Exit fullscreen mode

The above code has an issue. We should not use time.Sleep calls for synchronization between goroutines.

But go language does not have such a restriction mechanism, and the correctness of concurrent code seems to be based on experience.

Therefore, although the code passes the go compiler, there is a bug in the code logic.

I only know two places:

But I am looking for other places. Any suggestion? Thanks!

Top comments (1)

Collapse
 
nickkobishev profile image
Nick Kobishev

You should try gophers.slack.com/?redir=%2Fmessag...

And the #review channel.
Good luck!

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠