Error: Package awesomeProject contains more than one main function Consider using File kind instead

简介: Goland编辑器运行时出现“edit configuration”窗口,阻碍代码执行。解决方法:右键点击源文件运行。问题源于Go语言不支持函数重载,同一包内不能有两个同名函数,导致多入口冲突。初学者在main包中使用了多个Go源文件,应改为仅有一个源码文件来避免此问题。

问题

代码旁边有个绿色的箭头,点击运行时自动弹窗出来 edit configuration 窗口 ,导致无法运行

解决方法

在源文件上点击右键运行就可以了

问题出现原因:

goland函数不支持重载,一个包不可以有两个函数名一个的函数,如果同时出现两个函数执行入口,系统就无法选择正确的执行入口从而报错。

在初学阶段,在 main包中尝试了两个 go源码文件,所以会出现以上错误

通常情况下, main函数所在的包应该保持仅有一个 go源码文件就好了

相关文章
|
10月前
|
Java 关系型数据库 数据库连接
java中调用postgis的函数找不到,报错[42883] ERROR: function st_area(public.geometry) does not exis,Navicat里面正常
今天在postgresql数据库中对一个图层表使用st_area()函数,获取图层中geometry字段的面积。
|
6月前
Fatal error: Call to undefined function openssl_pkey_get_private()
Fatal error: Call to undefined function openssl_pkey_get_private()
38 0
|
10月前
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
74 0
|
5天前
|
计算机视觉 Python
error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
56 0
|
7月前
|
编译器 C语言
__FILE__, __LINE__ __FUNCTION__
__FILE__, __LINE__ __FUNCTION__
|
7月前
|
JavaScript Cloud Native Go
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
35 0
|
10月前
|
Linux
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
80 0
|
11月前
|
关系型数据库 MySQL C++
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
128 0
|
计算机视觉
cv2.error: OpenCV(4.5.2) : -1 : error: (-5:Bad argument) in function ‘rectangle‘
cv2.error: OpenCV(4.5.2) : -1 : error: (-5:Bad argument) in function ‘rectangle‘
224 0
|
计算机视觉
【在虚拟环境下完美解决】1698: error: (-215:Assertion failed) empty() in function cv::CascadeClassifier
首先我们要找到那个分类器所在的路径,我们可以在Cmd中直接输入【若是虚拟环境的话,则需要切换到对于虚拟环境中,再去查找对应的opencv版本与位置信息】
258 0

热门文章

最新文章