简体   繁体   中英

go run command not providing enough information to debug

when I was trying out scenarios on channels in go, I came across a code to reproduce deadlock as below

package main

import (
    "fmt"
)

func main() {
    c := make(chan bool)
    c <- true
}

when I run it using

go run gorouting.go

I am getting the below output

> main.main()
>         E:/GO Samples/gorouting.go:13 +0x57 
> exit status 2

but when I did run in https://play.golang.org I got more details about the exception, am I missing something in the command or do i need to do any configuration at the machine level?

fatal error: all goroutines are asleep - deadlock!

    goroutine 1 [chan send]:
    main.main()
        /tmp/sandbox592049259/main.go:7 +0x60

I am running with this configuration

go version go1.10.3 windows/amd64

Thanks for the help

When you use go run xxx.go go only compiles/runs that file within the main package...versus running go install && xxx where xxx is the name of your executable. go install builds everything and copies to the bin dir...try that locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM