I'd like to provide a similar interface than the one provided by a map in which you can get the value related to the key and know if the key was present in the map, but my attempts at it have failed so far.
Sample code Golang's play version:
package main
import "fmt"
type My map[string]string
func (m My) Get(key string) (string, bool) {
v, ok := m[key]
return v, ok
}
func main() {
my := make(My)
a := my.Get("hola")
fmt.Println("result : ", a)
}
This code will fail with:
prog.go:14: multiple-value my.Get() in single-value context
How can one mimic the sommeMap[key]? is it a built-in feature only?