Is it possible to update a value on in a struct using an anonymous function? In python I would do the following with a lambda:
inspect = lambda id: '/api/{}/inspect'.format(id)
Which would place the dynamic id
value in the string.
In Go
I am trying something like his:
type Info struct {
Inspect string
}
func Assign() Info {
i := &Info{}
i.Inspect = return func(id) {return fmt.Sprintf("/api/%s/inspect", id)}
return *i
}
But I want to update the value like this:
temp := Assign()
tempID := temp.Inspect("test")
fmt.Println("/api/test/inspect")