Question: I have a function works before using goroutine:

```
res, err := example(a , b)
if err != nil {
 return Response{
   ErrCode: 1,
   ErrMsg:"error",
 }
}

```

Response is a struct defined error info. When I use goroutine:

```
var wg sync.WaitGroup()
wg.Add(1)
go func(){
   defer wg.Done()
   res, err := example(a , b)
   if err != nil {
      return Response{
         ErrCode: 1,
         ErrMsg:"error",
    }
}()
wg.Wait()

```

Then I got

```
too many arguments to return
    have (Response)
    want ()

```

Answer: 
You need to use channel to achieve what you want:

```
func main() {
    c := make(chan Response)
    go func() {
        res, err := example(a , b)
        if err != nil {
            c <- Response{
                ErrCode: 1,
                ErrMsg:"error",
            }
        }
    }()
    value := <-c
}

```
The function you provide to span a go routine has no return in its signature. Go routines cannot return data. Running goroutine (asynchronously) and fetch return value from function are essentially contradictory actions. Simply put, goroutine cannot know where to return the data. Hence it doesnot allow it.

You can do something like this:

```
var response Response

var wg sync.WaitGroup
wg.Add(1)
go func() {
    defer wg.Done()
    res, err := example(a, b)
    if err != nil {
        response = res
    }
}()
wg.Wait()

return response

```