It’s common to bundle multiple outputs into a struct, and return them together over a single channel.
type Result struct {
Message string
Error error
}
ch := make(chan Result)
Related Contents:
- Does Go provide REPL?
- From io.Reader to string in Go
- How to set HTTP status code on http.ResponseWriter
- When to use os.Exit() and panic()?
- What’s the best way to bundle static resources in a Go program?
- How to stop http.ListenAndServe()
- Multiple goroutines listening on one channel
- Getting “bytes.Buffer does not implement io.Writer” error message
- How do you get the output of a system command in Go?
- Meaning of …interface{} (dot dot dot interface)
- Meaning of a struct with embedded anonymous interface?
- Go-compiled binary won’t run in an alpine docker container on Ubuntu host
- How safe are Golang maps for concurrent Read/Write operations?
- How do I get the local IP address in Go?
- How to pipe several commands in Go?
- How to remove all contents of a directory using Golang?
- GOBIN not set: cannot run go install
- Golang append an item to a slice
- Terminating a Process Started with os/exec in Golang
- Go error: non-constant array bound
- Do Go switch/cases fallthrough or not?
- How to fix parsing go.mod module declares its path as “x” but was required as “y”
- How do I reverse an array in Go?
- All possible GOOS value?
- Error “can’t load package: package my_prog: found packages my_prog and main”
- Does Golang support variadic function?
- Golang method with pointer receiver [duplicate]
- Escape Variables with Printf
- Why can’t a string be nil in Go?
- invalid recursive type in a struct in go
- How to get the current function name
- Golang defer behavior
- Golang http request results in EOF errors when making multiple requests successively
- Go: returning from defer
- In Go is it possible to iterate over a custom type?
- How to remove an installed package using go modules
- Return default value for generic type
- Go linter in VS code not working for packages across multiple files?
- Timeout for WaitGroup.Wait()
- How to get URL in http.Request
- What does a function without body mean?
- Sharing a globally defined db conn with multiple packages
- How to “cast” a pointer back to a value in Golang?
- what is the purpose of `go mod vendor` command?
- How do I turn an io.Reader into a io.ReadCloser? [duplicate]
- Initialize array of interfaces in Golang
- How to use a goroutine pool
- Golang run on Windows without deal with the Firewall
- $GOPATH must not be set to $GOROOT, why not?
- How to embed file for later parsing execution use