Is a generic slice conversion function possible?
Let’s say we have two named types that derive from int:
Is a generic slice conversion function possible?
Let’s say we have two named types that derive from int:
Is a generic slice conversion function possible?
Let’s say we have two named types that derive from int:
Is a generic slice conversion function possible?
Let’s say we have two named types that derive from int:
Is a generic slice conversion function possible?
Let’s say we have two named types that derive from int:
Converting `func() Foo` to `func() any` in Golang?
Issue The immediate issue is that a function of type func() Foo cannot be assigned func() any in Golang. Perhaps this is an XY problem, so I will explain why exactly I am even in this situation. Example I essentially have something like a health check package as such (this is a simplified model for […]
Converting `func() Foo` to `func() any` in Golang?
Issue The immediate issue is that a function of type func() Foo cannot be assigned func() any in Golang. Perhaps this is an XY problem, so I will explain why exactly I am even in this situation. Example I essentially have something like a health check package as such (this is a simplified model for […]
Converting `func() Foo` to `func() any` in Golang?
Issue The immediate issue is that a function of type func() Foo cannot be assigned func() any in Golang. Perhaps this is an XY problem, so I will explain why exactly I am even in this situation. Example I essentially have something like a health check package as such (this is a simplified model for […]
Generics, type T of interface interpreted as value T or **T when used as pointer
I am new to Go programming and trying to utilize generic api of Go. I want to implement IEntity interface and use implemented structs to abstract mongo db collections.
Different behavior for different types using generics
I’m trying to write a generic parser that would do different things depending on the expected return type. As simplified example of what I’d like to do, already using a trick from another answer: