Auto-open merged pdf also in Linux

Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
This commit is contained in:
2020-04-23 16:41:25 +02:00
parent 8bcb48e012
commit ea67a94445
2 changed files with 13 additions and 6 deletions

4
.gitignore vendored
View File

@@ -25,3 +25,7 @@ _testmain.go
.settings .settings
*.code-workspace *.code-workspace
.vscode .vscode
# bin dir
bin
bin/*

View File

@@ -174,15 +174,18 @@ func mergeInvoices(files []string) string {
} }
func openPDF(fileName string) { func openPDF(fileName string) {
var cmd *exec.Cmd
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
cmd := exec.Command("cmd", "/C start "+fileName) cmd = exec.Command("cmd", "/C start "+fileName)
} else {
cmd = exec.Command("xdg-open", fileName)
}
err := cmd.Run() err := cmd.Run()
if err != nil { if err != nil {
log.Fatalf("Impossibile aprire il pdf con le fatture unite: %v\n", err) log.Fatalf("Impossibile aprire il pdf con le fatture unite: %v\n", err)
} }
} }
//TODO for Linux
}
func main() { func main() {
var fileName string var fileName string