我有一个简单的应用程序,它可以截取桌面的屏幕快照并将其发送到服务器,但是当我使用时:
go build -o out/testCap.exe -ldflags="-H=windowsgui -s -w" -trimpath testCap.go
当我尝试从服务器获取屏幕截图时进行编译并出现此错误:
[+] Downloading screenshot
[+] Connected to agent, start downloading the file name and file size
[+] Get filesize:
SD?[:
[+] Get file name:/�)c��3�v���/z����K]7Q>�u�^
����,���2h����(�,�Lh&��
[!] ERROR in file name: open /�)c��3�v���/z����K]7Q>�u�^
����,���2h����(�,�Lh&��: no such file or directory
[+] Downloading file ...
[+] Downloading file ... ok
使用(no -H = windowsgui)=:
进行编译时很奇怪go build -o out/testCap.exe -ldflags="-s -w" -trimpath testCap.go
一切正常:
[+] Downloading screenshot
[+] Connected to agent, start downloading the file name and file size
[+] Get filesize:58487
[+] Get file name:ict51B1-132149403.png
[+] Downloading file ...
[+] downlading 58368 bytes of 58487
[+] Downloading file ... ok
并在服务器上获取文件ict51B1-132149403.png。在客户端(windows)中,仅需单击2即可运行testCap.exe(不显示-H = windowsgui终端令人讨厌的黑屏)
代码有300多行,我花了两天的时间检查可能的错误,但是我看到只有-H = windowsgui参数才导致错误 我该怎么解决?
我也在Windows终端上尝试过
"testCap.exe" >nul 2>&1
但是我遇到了同样的问题 在go版本1.13 / 1.14
中进行了测试