Hi y'all, I'm having trouble with the "concurrent counter" exercise regarding goroutines, what am I doing wrong?
Here my code package main import "fmt" //define the count() function go count(num int, data [] int, ch chan int){ var occurrance int for _, iter := range data{ if num == iter{ occurrance ++ } } occurrance } func main() { data := []int{12, 45, 88, 42, 0, 98, 102, 42, 77, 42, 1, 8, 7, 55, 4, 12, 87, 90, 42, 42, 11, 2, 6, 53, 90, 100, 4, 32, 8} var num int fmt.Scanln(&num) ch1 := make(chan int) ch2 := make(chan int) go count(num, data[:len(data)/2], ch1) go count(num, data[len(data)/2:], ch2) fmt.Println(<-ch1 + <-ch2) } The compiler throws these errors: line: 5:1 syntax error: syntax error: non declaration statement inside function body