Fix the tailing newline issue
This commit is contained in:
parent
425c93fd9e
commit
e06f788658
|
@ -20,4 +20,4 @@
|
||||||
|
|
||||||
# Go workspace file
|
# Go workspace file
|
||||||
go.work
|
go.work
|
||||||
filter
|
open
|
7
open.go
7
open.go
|
@ -26,7 +26,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%v", err)
|
log.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
dirpath := home + "/.open/"
|
dirpath := home + "/.config/open/"
|
||||||
os.MkdirAll(dirpath, 0775)
|
os.MkdirAll(dirpath, 0775)
|
||||||
opener_file := dirpath + mtype.Extension()
|
opener_file := dirpath + mtype.Extension()
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("%v", err)
|
log.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
prog = string(content)
|
prog = strings.TrimSuffix(string(content), "\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Don't know how to open '%s' file. What program should I use? ", mtype.Extension())
|
fmt.Printf("Don't know how to open '%s' file. What program should I use? ", mtype.Extension())
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
@ -54,6 +54,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
command := strings.Split(prog, " ")
|
command := strings.Split(prog, " ")
|
||||||
|
command = append(command, file)
|
||||||
|
|
||||||
|
fmt.Printf("Running command: '%s'\n", command)
|
||||||
out, err := exec.Command(command[0], command[1:]...).Output()
|
out, err := exec.Command(command[0], command[1:]...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue