当前位置:网站首页>Go Build报错汇总(持续更新)
Go Build报错汇总(持续更新)
2022-08-02 03:26:00 【rockage】
- OS: Win10
- Golang : v1.17
1、Windows目录权限引发的问题
现象:
每次执行go build的时候,总是会报以下错误:open C:\Users\rocka\AppData\Local\Temp\go-build2905132708\b001\exe\a.out.exe:
The process cannot access the file because it is being used by another process.
go: failed to remove work dir: remove C:\Users\rocka\AppData\Local\Temp\go-build2905132708\b001\exe\a.out.exe:
The process cannot access the file because it is being used by another process.解决方案:
- 找到 C:\Users\rocka\AppData\Local, 鼠标右键点中 Temp 文件夹 > 属性 > 安全 > 高级
- 添加 > 主体:Everyone > 把所有权限都打开 > 应用 > 确定退出
问题解决。
2、编译robot-vgo报错:
首先安装Mingw 64:
- https://www.mingw-w64.org/downloads/ 下载安装 Msys2 (最好打开全局墙,安装时全默认)这个网址也一样:https://www.msys2.org/
- 出现虚拟Linux之后依次执行以下命令:
pacman -Syu
[执行完毕后窗口会自动关闭,重新从开始菜单打开MSYS2,继续操作]pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
如果报错:
error: mingw32: signature from “Christoph Reiter (MSYS2 development key) <[email protected]com>” is unknown trust
尝试以下操作:
rm -r /etc/pacman.d/gnupg/
pacman-key --init
pacman-key --populate msys2
curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig
pacman -U --config <(echo) msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
pacman -Syu
PS: 以上流程全盘默认下载大概需要1.95G,耗费时间有点多,要耐心等待,建议打开全局梯。最后,手工添加两个路径到系统PATH变量:C:\msys64\mingw64\bin
C:\msys64\mingw64\lib
打开一个windows cmd,输入:gcc -v
如果版本号显示正常,说明Mingw 64就算安装好了
编译Robotgo项目的时候,如果报错:
vendor\github.com\robotn\gohook\hook.go:22:10: fatal error: event/goEvent.h: No such file or directory
22 | #include “event/goEvent.h”
解决方法:
del go.mod
del go.sum
go mod init rogotgo(api是随便起的一个名字)
go build -o run.exe (最好打开全局墙)
问题解决。
编译时同名包在VSCODE中划红线问题
PS:此问题不影响正常使用,但在vscode会反复报错,烦不胜烦
解决:
如有自定义包如mysql_con,需要做以下操作:
cd mysql_con
del go.mod
del go.sum
go mod init mysql_con (注意不能和主程序的go.mod中相同)
go build -o run.exe (go会自动搜寻这个子目录下的依赖,如r.exe不是可执行文件,删除即可)
问题解决。
VSCODE报错:Error loading workspace: gopls requires a module at the root of your workspace问题
- 打开文件菜单 > 首选项 > 设置 > 输入:settings > 点击 [在settings.json中设置] > 添加一行:
"gopls": {
"experimentalWorkspaceModule": true
},
不用理会警告,存盘退出,重启VSCODE,问题解决。
PS:
设置好的VSCode环境,最好同步一下保存在云端,下次换电脑的时候可以轻松同步回来,方法是:
打开文件菜单 > 首选项 > 设置同步 > 点 [登录并打开] , 随便注册一个Microsoft Live账号或者Github账号即可。
后记
其实以上几个问题都跟包管理相关,一旦包管理乱套了,就会出现编译不通过的问题,解决起来也很简单:
- 删除go.mod
- 删除go.sum
- go mod init XXX (重新初始化go mod)
- go build 正常编译
问题解决。
题外话: 在全默认状态下,所有的第三方包都放在这个路径下:> C:\Users\用户名\go\pkg\mod
边栏推荐
- Pycharm packages the project as an exe file
- How to log in to Alibaba Cloud server using the admin account
- PHP realizes the automatic reverse search prompt of the search box
- (7) superficial "crawlers" process (concept + practice)
- File upload vulnerability
- Offensive and defensive world - novice MISC area 1-12
- A code audit notes (CVE - 2018-12613 phpmyadmin file contains loopholes)
- v-bind usage: class dynamic binding object array style style and function method
- hackmyvm: kitty walkthrough
- 命令执行漏洞
猜你喜欢
会计账簿、会计账簿概述、会计账簿的启用与登记要求、会计账簿的格式和登记方法
(4) Function, Bug, Class and Object, Encapsulation, Inheritance, Polymorphism, Copy
账务处理程序、记账凭证账务处理程序、汇总记账凭证账务处理程序、科目汇总表账务处理程序、会计信息化概述、信息化环境下会计账务处理的基本要求(此章出1道小题)
(4) 函数、Bug、类与对象、封装、继承、多态、拷贝
OPENSSL基本实验以及OPENSSL详解
PHP反序列化漏洞
借贷记账法下的账户结构、借贷记账法的记账规则、借贷记账法下的账户对应关系与会计分录
Phonebook
Offensive and defensive world - novice MISC area 1-12
12. What is JS
随机推荐
vim edit mode
Command Execution Vulnerability
学IT,找工作——移除链表元素
战场:3(双子叶植物)vulnhub走读
By figure, a (complete code at the end)
OPENSSL基本实验以及OPENSSL详解
敏感信息泄露
成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))
c语言用栈实现计算中缀表达式
文件上传漏洞
SQL注入(6)
CTF之xxe
会计凭证概述、原始凭证、原始凭证的种类、原始凭证的基本内容、原始凭证的填制要求、原始凭证的审核
【无标题】
Google Hacking
Anaconda报错:An unexpected error has occurred. Conda has prepared the above report 解决办法
元宇宙:为何互联网大佬纷纷涉足?元宇宙跟NFT是什么关系?
Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
hackmyvm: may walkthrough
CTF introductory notes ping