在golang中,如何将int类型的切片从一个函数返回到另一个函数?

I have used channels to communicate..

   b := make([]int,0)  //This is the slice I have created.

I was appending values to the slice and I want to transfer the final slice stored in b to be returned to another function.. I have used this code..

   slic := make(chan int)
   go func() { slic <- input()} ()
   slice := <-slic
   fmt.Println(slice)

I am getting this error:"can't use b (type []int) as type int in return argument."

Change your chan make to this:

make(chan []int)

Or select an index of your []int to send on your chan int.

Either way int and []int are distinct types, as chan int and chan []int are.