暂时不建议更新go1.18正式版

作者: aries 分类: Go 发布时间: 2022-03-16 08:11 ė 951次浏览 6 0评论

通过刚才的测试
发现 goland 对泛型支持有 bug ,能正常编译的代码报错,先降回 1.17 了
复现代码

package main

import "fmt"

type G[T any] struct {
Data []T
}

type D = G[int] // <- type alias or type definition both can trigger this bug.

func main() {
g := D{
Data: make([]int, 0), // goland will report a type error here.
}
fmt.Println(g)
}

换一个
暂无评论
Ɣ回顶部