Channels in golang are referenced type. It means that they are references to a place in the memory. The information can be used to achieve the goal.
Firstly, let’s consider using structs as the information carrier. This is the most intuitive choice for the purpose. Below you can find an example of a struct which will be used today.
type FuncResult struct { Err error Result int } func NewFuncResult(result int) FuncResult { return FuncResult{Result: result} } The idea is to create a channel from the struct, pass the channel to a function and wait for the result.