There is a third-party library that does some doIt () work for a very long time. You can run the execution of this function in a separate gorutin, but how to stop its implementation ahead of time?
func doIt() { // очень долго работает } func main() { result := make(chan int) go func() { result <- doIt() }{} fmt.Println(<-result) }