I’ve a Go undertaking that compiles efficiently with Go 1.22, however once I try to compile it with GCCGO, I encounter errors. The issue appears to be associated to the usage of generics.
Right here’s a simplified instance that fails to compile with GCCGO on Go 1.18:
bundle primary
import (
"fmt"
)
sort Keyring[T any] struct {
ServiceName T
}
func New[T any](serviceName T) *Keyring[T] {
return &Keyring[T]{ ServiceName: serviceName }
}
func primary() {
kr := New("instance.com")
fmt.Println(kr.ServiceName)
}
I perceive that generics had been launched in Go 1.18, so this code ought to theoretically compile.
Moreover, I’m experiencing a problem in VSCode the place imports for built-in packages like fmt and encoding aren’t acknowledged, though the undertaking compiles with out errors.
Has anybody else encountered comparable points when compiling with GCCGO and utilizing generics? Any options on find out how to resolve these compilation and VSCode import recognition issues can be significantly appreciated.