On Wed, Feb 12, 2025 at 11:34 PM David Karr wrote:
>
> Ok, good to know. How do I solve this problem? It almost looks like I have to
> create a slice of the generic type and iterate through the entries in the
> commitsCache result, doing a type conversion of every entry.
I don't know what probl
So, for instance, this appears to compile, but I haven't run it yet:
func getFromCommitsCache[T any](project string, repo string, branch string)
([]T, bool) {
commitsCacheMutex.RLock()
defer commitsCacheMutex.RUnlock()
var result []T
if commits, found := commitsCache[project+"/"+re
Ok, good to know. How do I solve this problem? It almost looks like I have
to create a slice of the generic type and iterate through the entries in
the commitsCache result, doing a type conversion of every entry.
On Wednesday, February 12, 2025 at 2:15:03 PM UTC-8 Jan Mercl wrote:
> On Wed, Feb
On Wed, Feb 12, 2025 at 10:54 PM David Karr wrote:
`[]any` is a slice type (https://go.dev/ref/spec#Slice_types), not an
interface type (https://go.dev/ref/spec#Interface_types).
But type assertions, as in `expr.(someType)`, are valid only for
interface types: https://go.dev/ref/spec#Type_assert
I don't expect this should be very difficult, go-wise, but I haven't
written much code with generics yet.
I have an application that can read commits from either github or
bitbucket, but each run will either be for bitbucket or github, not both.
I have to retrieve the commits for a branch a co