The code you wrote is using a generic value, but it is not itself generic.
There is only one instantiated version of the runInt() function, and it
knows (at compile-time!) that mySet is an map[int]int.
Make that function actually generic - something like:
func testThing[K comparable, V any](m
[]byte is a no comparable type.
quoting the docs:
*comparable is an interface that is implemented by all comparable
types(booleans, numbers, strings, pointers, channels, interfaces,arrays of
comparable types, structs whose fields are all comparable types).The
comparable interface may only
NewThing[int, int]() returns a map[int]int, and therefore that's the type
of MySet in func runInt.
You can think of NewThing[T1, T2] as a family of functions, like
func NewThing_int_int() map[int]int { ... }
func NewThing_int_byteslice() map[int][]byte { ... }
... etc
On Wednesday, 15
when writing type parameterized code, it has to work with anything that
could be passed to it.
but once instantiated, the type is known and it can be used with its
concrete type
like `map` can be thought of as declared to be `map[comparable]any`
but when you use it, the type is always known,