3 ms·
I thought it was a pain in the ass until I realized golang really does have a sort of dynamic parameter: func test(myVar interface{}) will accept any type
by maxk42 13y ago
I thought it was a pain in the ass until I realized golang really does have a sort of dynamic parameter:
func test(myVar interface{})
will accept any type at all. You can then use Go's type switch or a call to reflect.TypeOf() to invoke different behavior based on the parameter's type. To my way of thinking, it's pretty simple.