I'm trying to make a function that accept 2 parameters, and set value of second parameter to first one, it might looks like(I'm not sure):
func set(a interface{}, b interface{}) {
// do something to make a = b
}
it works like this:
a := 0
b := 10
set(&a, b)
// here a should be 10
s1 := ""
s2 := "what"
set(&s1, s2)
// here s1 should be "what"
it is expected to work on all basic types, like ints, floats, strings, bool, ...
How can I acheive this?
Aucun commentaire:
Enregistrer un commentaire