package main

import "fmt"

func calcSum(s []int, ch chan<- int) {
    result := 0
    for _, v := range s {
        result += v
    }
    ch <- result
}

func main() {
    
    ch := make(chan int)
    
    numbers := []int{1,2,3,4,5,6,7,8,9,10}
    
    go calcSum(numbers[:5], ch)
    go calcSum(numbers[5:], ch)
    
    var total int
    
    for range [2]int{} {
        total += <-ch
    }       

    close(ch)
    
    fmt.Println("Total:", total)
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: