Go语言访问被拒绝

huangapple go评论120阅读模式
英文:

Go lang access denied

问题

我是你的中文翻译助手,以下是你要翻译的内容:

我对GO编程语言还不熟悉,我想做的是将一些项目放入映射中,然后删除其中一个。当我尝试从数组中删除其中一个项目时,我收到了错误消息:

C:/Go\bin\go.exe run C:/Users/Computer/IdeaProjects/untitled1/simple.go
fork/exec C:\Users\Computer\AppData\Local\Temp\go-build143466426\command-line-arguments\_obj\exe\simple.exe: Access is denied.

代码如下:

package main

import "fmt"

func main(){

    presAge := make(map[string] int)

    presAge["test"] = 42
    presAge["boom"] = 421

    delete(presAge,"boom")

    fmt.Println(len(presAge))

}
英文:

I'm new to the GO programming language, what I'm trying to do is to put some items into the map and then remove one of them, when I'm trying to remove one of the items from array I'm getting the error message:

C:/Go\bin\go.exe run C:/Users/Computer/IdeaProjects/untitled1/simple.go
fork/exec C:\Users\Computer\AppData\Local\Temp\go-build143466426\command-line-arguments\_obj\exe\simple.exe: Access is denied.

the code:

package main

import "fmt"

    func main(){
    
    	presAge := make(map[string] int)
    
    	presAge["test"] = 42
    	presAge["boom"] = 421
    
    	delete(presAge,"boom")
    
    	fmt.Println(len(presAge))
    
    }

答案1

得分: 14

我只能就我的情况说一下。我在使用Windows 10时遇到了类似的错误。经过一些实验,看起来错误是由我使用的反病毒软件Avira引起的。基本上,Avira将.exe文件检测为包含某种病毒的模式(在我这里是称为HEUR/APC (Cloud)),这会阻止程序的执行。

在我禁用了反病毒软件之后,一切恢复正常。

英文:

I can only speak for my own case. I ran into the similar error using Windows 10. After some experiments, it looks like the error came from Avira, the anti-virus software I was using. Basically, the .exe file is detected by Avira as containing the pattern of a type of virus (called HEUR/APC (Cloud) in my case), which prevents the program from executing.

After I disabled my anti-virus software, everything went back to normal.

答案2

得分: 7

对于我来说,我使用的是 Avira,只需将 C:\Users\Computer\AppData\Local\Temp 文件夹添加到实时保护的例外文件夹中。

问题已解决。

英文:

for me I used avira just add C:\Users\Computer\AppData\Local\Temp floder to exception folder for realtime-protection.

Solved my problem

答案3

得分: 4

**** 仅适用于您的计算机上安装了Avira防病毒软件 ****

问题是Avira将Go解释器识别为某种病毒(HEUR/APC)。
因此它会阻止它并出现此错误。

查看第一行

只需在同一页的设置中添加一个文件夹的例外,就像我所做的那样。

将此路径添加到例外:C:\Users\User\AppData\Local

然后按下确定并应用,您就可以继续使用了。

附注:我看到还有其他人指出这是Avira防病毒软件,但没有给出正确的解决方案,所以我想从我的角度给出一个正确的解决方案。

英文:

**** Only Applies if you have avira antivirus installed on your pc ****

The thing is that avira recognises the go interpreter similar to a certain virus(HEUR/APC).
So it blocks it and we get this error.

see the first row

Just go to settings in the same page and add a exception to a folder like i have done so.

add this path to the exception : C:\Users\User\AppData\Local

Then press Ok and apply and you'll be good to go.

P.S. - I see that someone else also pointed out that it's the avira antivirus but didn't give proper solution to the problem, so i thought to give a proper solution from my side.

答案4

得分: 2

你的代码是正确的。
你可以通过https://play.golang.org/运行它,它会打印出"1"。

你遇到的错误不是Go语言的错误,而是Windows的错误。
看起来像是权限问题(不知道为什么会出现这个错误)。

英文:

Your code is correct.
You can run it via https://play.golang.org/ and it will print "1"

The error you're getting is not a Go error but a Windows error.
It looks like a permission problem (no idea why you're getting it)

答案5

得分: 2

所以这里的诀窍是,在Windows中需要以管理员身份运行您的应用程序。

英文:

so the trick here is that you need to run your application as Administrator in Windows

答案6

得分: 1

这对我来说有效,因为我没有管理员权限来禁用我的防病毒软件。

运行以下命令:go build main.exe; main./exe

英文:

This worked for me as I had no admin rights to deactivate my antivirus

go build main.exe; main./exe

答案7

得分: 1

我现在是你的中文翻译助手,以下是翻译好的内容:

我遇到的情况是
%userprofile%\AppData\Local\Temp
同样的错误
在将此目录添加到360的信任列表后问题解决了。

英文:

The situation I have is
%userprofile%\AppData\Local\Temp
same error
Problem solved after I added this directory to 360's trust list

答案8

得分: 1

将代码文件夹添加到例外列表中解决了这个问题。

Windows 安全性-> 病毒和威胁防护设置-> 排除-> 添加文件夹

在这里添加你的工作文件夹,即代码所在的位置。添加临时文件夹对我来说没有起作用。

使用上述命令(常规命令提示符)可以消除弹出的警报,但不知道原因。

英文:

Adding code folder to the exception list solved the problem

Windows Security-> Virus and Threat Protection Settings -> Exclutions->Add folder

Add your workplace folder here where your code exists. Adding temp folder didn't work for me.

go build gotest.go ; .\gotest.exe

Using the above command (regular command prompt.) can eliminate pop-up alerts but don't know the reason.

答案9

得分: 0

我遇到了相同的错误,这是因为我的Cylance Protect防病毒软件。尝试禁用它。

英文:

I am getting the same error and its because of my Cylance Protect antivirus. Try disabling it.

答案10

得分: 0

这也发生在我身上,但这不是一个Go的问题,而是一个Windows的问题。我没有运行任何杀毒软件,所以我做的是,如果我要使用Go(无论是哪个文本编辑器),我以管理员身份运行它。这解决了我的问题(仅适用于WINDOWS)。

英文:

This happened to me too, but it's not a Go problem, it's a Windows problem. I didn't have any antivirus going on, so what I did was that if I was going to work with Go, (whatever the text editor) I run it as admin. That solved my problem (WINDOWS only)

答案11

得分: 0

我遇到了类似的情况,当我关闭了我的防病毒软件后,问题就消失了。我建议你也试一试。

英文:

I experienced a similar situation and when I turned off my antivirus, the problem disappeared. I recommend you give it a try.

huangapple
  • 本文由 发表于 2017年3月26日 01:28:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/43019581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定