package main import ( "fmt" "time" ) func delayerSum(c chan int) { val := 0 for i := 0; i < 10; i++ { val = val + 1 } time.Sleep(time.Second * 5) c <- val } func main() { fmt.Println("Starting the delayed function, please wait") loading := "Loading." for i := 0; i < 2; i++ { fmt.Printf("\r%v", loading) loading = loading + "." time.Sleep(time.Second) } delSum := make(chan int) go delayerSum(delSum) finalValue := <-delSum fmt.Println(finalValue) }