]> git repos ~mattia - go-utility.git/commitdiff
Editor v0.0.5
authorMattia Cabrini <dev@mattiacabrini.com>
Tue, 15 Aug 2023 09:55:58 +0000 (11:55 +0200)
committerMattia Cabrini <dev@mattiacabrini.com>
Tue, 15 Aug 2023 09:55:58 +0000 (11:55 +0200)
editor.go [new file with mode: 0644]

diff --git a/editor.go b/editor.go
new file mode 100644 (file)
index 0000000..a5a17b6
--- /dev/null
+++ b/editor.go
@@ -0,0 +1,22 @@
+// Copyright (c) 2023 Mattia Cabrini
+// SPDX-License-Identifier: MIT
+
+package utility
+
+import (
+       "os"
+       "os/exec"
+)
+
+func Editor(editorPath string, path string) (err error) {
+       editor := exec.Command(editorPath, path)
+       editor.Stdin = os.Stdin
+       editor.Stderr = os.Stderr
+       editor.Stdout = os.Stdout
+
+       if err = editor.Run(); err != nil {
+               return
+       }
+
+       return
+}