| 1 | //go:build windows |
| 2 | |
| 3 | package cli |
| 4 | |
| 5 | import "syscall" |
| 6 | |
| 7 | // hideFileWindows sets the FILE_ATTRIBUTE_HIDDEN flag on the given path so |
| 8 | // stale .old binaries left behind by self-update don't clutter the directory. |
| 9 | // Best-effort: errors are silently ignored. |
| 10 | func hideFileWindows(path string) { |
| 11 | p, err := syscall.UTF16PtrFromString(path) |
| 12 | if err != nil { |
| 13 | return |
| 14 | } |
| 15 | // FILE_ATTRIBUTE_HIDDEN = 0x02 |
| 16 | syscall.SetFileAttributes(p, 0x02) |
| 17 | } |
| 18 |