[Web Feed] One of the most common issues novice Go programmers run into is the inability...
Feed Supplier <[email protected]> Mon, 10 May 21 01:28:30 UTC
| Newsgroups | alt.comp.programming |
|---|---|
| Organization | Usenet.Farm |
| Message-ID | <[email protected]> |
.. to pass a slice of a concrete type (e.g. []int64) into a funct
One of the most common issues novice Go programmers run into is the inability to pass a slice of a concrete type (e.g.
[]int64
) into a function that expects a slice of interfaces (e.g.
[]interface{}
or something like
[]fmt.Stringer
). Why is that?
In this post, I'm going to list several answers to this question, diving into some interesting implementation details of how Go works under the hood.
Link 1
Go internals: invariance and memory layout of slices - Eli Bendersky's website: https://eli.thegreenplace.net/2021/go-internals-invariance-and-memory-layout-of-slices