Go 编译后删除临时文件 temp.go
const TEMP = 'temp.go'
err = exec.Command("go", "build", "-trimpath", "-ldflags", "-w -s", "-o", output, TEMP).Run() if err != nil { println("[!] Compile fail: " + err.Error()) return }
defer os.Remove(TEMP)
This will ensure that the 'temp.go' file is deleted after the compilation is complete, regardless of whether or not there was an error.
原文地址: https://www.cveoy.top/t/topic/lU31 著作权归作者所有。请勿转载和采集!