Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.18rc1 linux/amd64
Does this issue reproduce with the latest release?
go1.18rc1 seems to be the latest at the moment. (Mon Mar 7 09:50:11 AM CET 2022
)
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/adamluzsi/.cache/go-build" GOENV="/home/adamluzsi/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/adamluzsi/pkg/mod" GONOPROXY="*" GONOSUMDB="*" GOOS="linux" GOPATH="/home/adamluzsi" GOPRIVATE="*" GOPROXY="direct" GOROOT="/home/adamluzsi/dist/golang.org/1.18rc" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/adamluzsi/dist/golang.org/1.18rc/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18rc1" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/adamluzsi/src/github.com/adamluzsi/frameless/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4186401866=/tmp/go-build -gno-record-gcc-switches"
What did you do?
package bug
import "io"
type Iterator[T any] interface {
// Closer is required to make it able to cancel iterators where resource being used behind the scene
// for all other case where the underling io is handled on higher level, it should simply return nil
io.Closer
// Next will ensure that Decode return the next item when it is executed
Next() bool
// Err return the cause if for some reason by default the More return false all the time
Err() error
// Value returns the current value from the iterator.
Value() T
}
// fails with:
// ./bug.go:19:22: cannot use generic type Iterator[T any] without instantiation
type IteratorAlias = Iterator
What did you expect to see?
Based on the following document guidance: go.googlesource.com/proposal#generic-type-aliases
I hoped that I can make a type alias for a type that has type parameters with refactoring purposes.
What did you see instead?
./bug.go:19:22: cannot use generic type Iterator[T any] without instantiation
Let me know if I can help with the issue,
and thank you very much for your support!