// Sometimes you end up typing this having to return
// a value you made up but don't care about.
func f1() (int, error) {
return -1, errors.New("something went wrong")
}
// Or maybe like this with named return values.
func f2() (a int, err error) {
return a, errors.New("something went wrong")
}
// It would be nice if you could type this instead.
//
// The underscore being used here to return whatever is in
// the return slot when the return statement is executed.
func f() (a int, err error) {
return _, errors.New("something went wrong")
}
The last doesn't compile of course, it gives
cannot use _ as value or type
Being able to use _ seems like a nice convenience to me. What it actually returns is completely defined. And it would save us having to figure out types for stuff that you can't use `nil` for, eg `time.Time` is particularly annoying.
Thoughts?