Fix the tailing newline issue

This commit is contained in:
Sameer Rahmani 2022-11-26 12:06:01 +00:00
parent 425c93fd9e
commit e06f788658
2 changed files with 6 additions and 3 deletions

2
.gitignore vendored
View File

@ -20,4 +20,4 @@
# Go workspace file
go.work
filter
open

View File

@ -26,7 +26,7 @@ func main() {
if err != nil {
log.Fatalf("%v", err)
}
dirpath := home + "/.open/"
dirpath := home + "/.config/open/"
os.MkdirAll(dirpath, 0775)
opener_file := dirpath + mtype.Extension()
@ -35,7 +35,7 @@ func main() {
if err != nil {
log.Fatalf("%v", err)
}
prog = string(content)
prog = strings.TrimSuffix(string(content), "\n")
} else {
fmt.Printf("Don't know how to open '%s' file. What program should I use? ", mtype.Extension())
reader := bufio.NewReader(os.Stdin)
@ -54,6 +54,9 @@ func main() {
}
command := strings.Split(prog, " ")
command = append(command, file)
fmt.Printf("Running command: '%s'\n", command)
out, err := exec.Command(command[0], command[1:]...).Output()
if err != nil {
log.Fatal(err)