()
| 1 | func process() { |
| 2 | executablePath, err := os.Executable() |
| 3 | if err != nil { |
| 4 | // 处理错误 |
| 5 | return |
| 6 | } |
| 7 | |
| 8 | sourceFilename := filepath.Base(executablePath) // 源文件名称 |
| 9 | processName := filepath.Base(os.Args[0]) // 当前运行进程名称 |
| 10 | |
| 11 | // 比较源文件名称和进程名称是否相同 |
| 12 | if strings.EqualFold(sourceFilename, processName) { |
| 13 | // 进程名称和源文件名称相同,正常运行 |
| 14 | // 在这里执行正常的操作 |
| 15 | } else { |
| 16 | // 进程名称和源文件名称不同,可能在沙箱环境中运行 |
| 17 | // 在这里执行相应的防沙箱操作 |
| 18 | os.Exit(0) // 退出程序 |
| 19 | } |
| 20 | } |
nothing calls this directly
no outgoing calls
no test coverage detected