哇靠,1.18 release!

2022-03-16 01:41:54 +08:00
 Immortal
我先更为敬了🐶
终于出来了,不容易
9408 次点击
所在节点    Go 编程语言
45 条回复
Carseason
2022-03-16 02:13:29 +08:00
赶紧冲
Trim21
2022-03-16 04:44:31 +08:00
发现 goland 对泛型支持有 bug ,能正常编译的代码报错,先降回 1.17 了
Trim21
2022-03-16 04:59:56 +08:00
Carseason
2022-03-16 05:38:01 +08:00
@Trim21 可以啊
Trim21
2022-03-16 05:46:46 +08:00
@Carseason #4 哎,试了一下现在这个写法的确可以。想当然了。编辑了一下,现在应该能触发 goland 的 bug 了
Trim21
2022-03-16 05:48:06 +08:00
type alias 或者 type definition 都能触发
Carseason
2022-03-16 05:52:58 +08:00
@Trim21 sogo 我用的 vscode 你 gomod 指定 1.18 了么?
Trim21
2022-03-16 05:54:03 +08:00
@Carseason 对,不指定 1.18 也编译不了…
iyear
2022-03-16 07:35:33 +08:00
终于发了,看着 milestone 一点点到底
tulongtou
2022-03-16 08:19:39 +08:00
范型也太丑了
FakNoCNName
2022-03-16 08:43:15 +08:00
本来大项目的代码就不容易阅读,这下子到处抽象更晦涩了
darksword21
2022-03-16 08:47:05 +08:00
起床更
hingbong
2022-03-16 09:02:07 +08:00
@Trim21 就是 1.18 才支持泛型的,正常,idea 2022.1eap 上没复现 bug
eudore
2022-03-16 09:02:42 +08:00
升级完成
macscsbf
2022-03-16 09:15:21 +08:00
goland 还有些 bug, 这里放在 goland 里会报红 但是我能编译
type Binding[S types.Stringer, P any] interface {
Name() S
Bind(P, any) error
}

type testBinding[S types.Stringer, P *http.Request] struct {
}

func NewTestBinding[S types.Stringer, P *http.Request]() Binding[S, P] {
return &testBinding[S, P]{}
}

func (t testBinding[S, P]) Name() S {
return "name"
}

func (t testBinding[S, P]) Bind(p P, a any) error {
return nil
}
macscsbf
2022-03-16 09:16:12 +08:00
types.Stringer 是自定义的一个类型
type Stringer interface {
~string
}
macscsbf
2022-03-16 09:18:46 +08:00
func IndexOf[T comparable](collection []T, target T) int {
for i, t := range collection {
if t == target {
return i
}
}
return -1
}
zhs227
2022-03-16 09:19:45 +08:00
goland 一般要再等一个版本更新才能解决提示报错问题。
rrfeng
2022-03-16 09:25:52 +08:00
不是 gopls 的 bug 吗
wzw
2022-03-16 09:32:37 +08:00
@zhs227 等新版本再试试 1.18

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/840640

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX