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.

Go 编译后删除临时文件 temp.go

原文地址: https://www.cveoy.top/t/topic/lU31 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录