I want to open a PDF file in the file system, starting with the default application. How can i do this? From the command line, I simply write the name of the pdf file and the application opens (with the requested file). When I try to use exec.Command() , I get an error (not surprisingly) exec: "foo.pdf": executable file not found in %PATH% .
package main import ( "log" "os/exec" ) func main() { cmd := exec.Command("foo.pdf") err := cmd.Start() if err != nil { log.Fatal(err) } err = cmd.Wait() if err != nil { log.Fatal(err) } }
source share