2021-12-01 19:18:20 +03:00
|
|
|
//go:build windows && (!linux || !darwin || !freebsd || !netbsd || !openbsd)
|
2020-12-14 22:28:07 +03: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-23 01:49:07 +03:00
|
|
|
proc := exec.Command("rundll32", "url.dll,FileProtocolHandler", path)
|
|
|
|
err := proc.Start()
|
2020-12-14 22:28:07 +03:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2021-12-23 01:49:07 +03:00
|
|
|
go proc.Wait() // Prevent zombies, see #219
|
2020-12-14 22:28:07 +03:00
|
|
|
return "Opened in default system viewer", nil
|
|
|
|
}
|