Prevent .bat file closing when I run Go script via drop down

82 Views Asked by At

I have this little Hello World program written in Go:

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

I use Sublime Text 3 with GoSublime. Something misconfigured, because Tools -> Build command not working, just only when I type in the console:

go build

Then the editor creating the .exe program.

So I want to use a basic .bat file, where I drag and drop my hello.go program:

@echo off
cd /d "%~dp0"
start "" "C:\Go\bin\go.exe" "run" "%~f1" pause

It runs without problem, but unfortunately closes when it's finished.

Can You help to solve this? ;)

1

There are 1 best solutions below

0
On BEST ANSWER

It's just that start launches it in it's own process?

so:

@echo off
cd /d "%~dp0"
C:\Go\bin\go.exe run %~f1 
pause

Should work?