I wonder if there is a way to implement a function that behaves similar to map getter: it returns return value as first argument and (optionally assigned) second value ok
as second argument. So I need function f
that I can call in following ways:
value1 := f(1)
value2, ok := f(2)
No, it can't be done, the only option is to return a pointer and check if it's nil.
if v := f(10); v != nil {
//stuff
}