2021-12-01 11:18:20 -05:00
|
|
|
//go:build windows && (!linux || !darwin || !freebsd || !netbsd || !openbsd)
|
2020-12-14 14:28:07 -05:00
|
|
|
// +build windows
|
|
|
|
// +build !linux !darwin !freebsd !netbsd !openbsd
|
|
|
|
|
|
|
|
package sysopen
|
|
|
|
|
|
|
|
import "os/exec"
|
|
|
|
|
|
|
|
// Open opens `path` in default system vierwer.
|
|
|
|
func Open(path string) (string, error) {
|
2021-12-22 17:49:07 -05:00
|
|
|
proc := exec.Command("rundll32", "url.dll,FileProtocolHandler", path)
|
|
|
|
err := proc.Start()
|
2020-12-14 14:28:07 -05:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2021-12-22 20:39:17 -05:00
|
|
|
//nolint:errcheck
|
2021-12-22 17:49:07 -05:00
|
|
|
go proc.Wait() // Prevent zombies, see #219
|
2020-12-14 14:28:07 -05:00
|
|
|
return "Opened in default system viewer", nil
|
|
|
|
}
|