go exec 无法执行 windows 基础命令

go exec 无法执行 windows 基础命令:(del: executable file not found in %path%)

package main

import(
"fmt"
"os/exec"
)

func main(){
// c := exec.Command("del", "D:\a.txt") 该语句无法找到 del.exe
c := exec.Command("cmd", "/C", "del", "D:\a.txt")

if err := c.Run(); err != nil {
fmt.Println("Error: ", err)
}
}

参考文档

Go 打包后的文件被识别为木马文件

go build github.com/beancount-gs: open a.out.exe: Operation did not complete successfully because the file contains a virus or potentially unwanted software.

We have removed the detection. Please follow the steps below to clear cached detection and obtain the latest malware definitions.

1. Open command prompt as administrator and change directory to c:\Program Files\Windows Defender
2. Run “MpCmdRun.exe -removedefinitions -dynamicsignatures”
3. Run "MpCmdRun.exe -SignatureUpdate"

Alternatively, the latest definition is available for download here: https://www.microsoft.com/en-us/wdsi/definitions

解决方案:Go 1.16 for windows - trojan detection · Issue #44351 · golang/go (github.com)
官方说明:Frequently Asked Questions (FAQ)