当前位置:网站首页>Syntax error of go language generic in IDE
Syntax error of go language generic in IDE
2022-06-26 04:04:00 【Hand grinding procedure】
Problem description
Use goland Use generics ,go Version is :
go version go1.18.1 windows/amd64
Write code :
func Test[T any](a, b T) T {
return a
}
func Add[T string | int | int64 | float64](a, b T) T {
return a + b
}
func main() {
fmt.Println("hello")
res := Test(1.1, 2.2)
fmt.Println(res)
}
There are the following problems :
#command-line-arguments
.\demo02.go:5:17: syntax error: unexpected type, expecting ]
resolvent
This is because goland Generic format not supported : Some versions can be extended with external tools :
The official website tutorial is as follows
https://blog.jetbrains.com/go/2020/11/24/experimenting-with-go-type-parameters-generics-in-goland/
It is recommended to update directly to 2022 Later versions
边栏推荐
- Sorting out the knowledge points of the renderview renderobject parentdata of the shuttle
- 線程同步之讀寫鎖
- R language and machine learning
- Spark - 一文搞懂 parquet
- 开源!ViTAE模型再刷世界第一:COCO人体姿态估计新模型取得最高精度81.1AP
- (15)Blender源码分析之闪屏窗口显示菜单功能
- 线程同步之互斥量(互斥锁)
- Introduction of mybatis invalid
- 1. foundation closing
- 高性能算力中心 — RoCE — Overview
猜你喜欢
Matplotlib multi line chart, dot scatter chart
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
Analysis of camera memory memory leakage (II)
Judge the same value of two sets 𞓜 different values
win10 系统打开的软件太小,如何变大(亲测有效)
ABP framework
How does virtual box virtual machine software accelerate the network speed in the virtual system?
线程同步之条件变量
線程同步之讀寫鎖
【Flink】Flink Sort-Shuffle写流程简析
随机推荐
R language and machine learning
Optimization - multi objective planning
Three level menu applet
[QT] resource file import
Open Camera异常分析(一)
asp. Net web page, ASP connects to the database, and uses asp:panel and asp:dropdownlist controls
Link monitoring pinpoint
Camera-memory内存泄漏分析(二)
Small record of neural network learning 71 - tensorflow2 deep learning with Google Lab
win10 系统打开的软件太小,如何变大(亲测有效)
Flask入门
MapReduce execution principle record
After a test of 25K bytes, I really saw the basic ceiling
【Flink】Flink源码分析——批处理模式JobGraph的创建
matplotlib折线图,文字显示,win10
763. dividing alphabetic intervals
线程同步之条件变量
[QT] dialog box
Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond