I have a command line tool written in Golang and I need to run vim from it. However, it does not work, and there is no mistake with it or anything else. I shortened the code to this:
package main
import (
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("vim", "test.txt")
err := cmd.Run()
fmt.Println(err)
}
When I run this, I see the vim process for 2-3 seconds, but the application does not actually open. Then the program just exits (and the vim process closes) with "exit status 1".
I also tried to capture stderr:
package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("vim", "test.txt")
var stderr bytes.Buffer
cmd.Stderr = &stderr
err := cmd.Run()
fmt.Println(err)
fmt.Println(stderr)
}
But in this case, the program is stuck endlessly.
Any idea what could be the problem?
source
share