goutils/other/other.go
2024-01-17 09:47:33 +01:00

15 lines
368 B
Go

package other
// OutputIntoChannel takes a singular return value and sends it into the target channel.
// This is a wrapper for functions where a value can't be collected from directly.
// Example: goroutines
func OutputIntoChannel[T any](out T, target chan T) {
target <- out
}
func Must[T any](val T, err error) T {
if err != nil {
panic(err)
}
return val
}