当前位置:网站首页>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 -Supacman -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\binC:\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
边栏推荐
- Alfa: 1 vulnhub walkthrough
- The CTF introduction of PHP file contains
- 库存现金、现金管理制度、现金的账务处理、银行存款、银行存款的账务处理、银行存款的核对
- uniapp | Problems with the use of the official map component
- Alfa: 1 vulnhub walkthrough
- 动力:2 vulnhub预排
- 强化学习笔记:DDPG
- WeChat applet development video loading: [Rendering layer network layer error] Failed to load media
- (2) 顺序结构、对象的布尔值、选择结构、循环结构、列表、字典、元组、集合
- VIKINGS: 1 vulnhub walkthrough
猜你喜欢

命令执行漏洞

xxe of CTF

CSRF(跨站请求伪造)

A network security guinea pig's learning path - scripting of advanced usage of nmap

hackmyvm: juggling walkthrough

hackmyvm-hopper walkthrough

(6) Design of student information management system

The CTF introductory notes of SQL injection

(3) string

(7) superficial "crawlers" process (concept + practice)
随机推荐
利用cookie获取admin权限 CTF基础题
The CTF introduction of PHP file contains
真·杂项:资本论阅读笔记(随缘更新)
Smart Tips for Frida Scripting in Kali Environment
Anaconda报错:An unexpected error has occurred. Conda has prepared the above report 解决办法
一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用
Solve the problem of Zlibrary stuck/can't find the domain name/reached the limit, the latest address of Zlibrary
SATA M2 SSD 无法安装系统的解决方法
账务处理程序、记账凭证账务处理程序、汇总记账凭证账务处理程序、科目汇总表账务处理程序、会计信息化概述、信息化环境下会计账务处理的基本要求(此章出1道小题)
(4) 函数、Bug、类与对象、封装、继承、多态、拷贝
hackmyvm: juggling walkthrough
v-bind usage: class dynamic binding object array style style and function method
3000字入门图神经网络
SQL注入(6)
ES6 iterator explanation example
CTF-网鼎杯往届题目
战场:3(双子叶植物)vulnhub走读
The first time to tear the code by hand, how to solve the problem of full arrangement
CSRF(跨站请求伪造)
(2) Sequence structures, Boolean values of objects, selection structures, loop structures, lists, dictionaries, tuples, sets