Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francoishill/318423cf69f62eadf4d1 to your computer and use it in GitHub Desktop.
Save francoishill/318423cf69f62eadf4d1 to your computer and use it in GitHub Desktop.
A snippet to quickly generate a batch file to build/run a go app. In your folder with main.go, just create a new "run.bat" file and trigger this snippet by typing `run_go_app`.
<snippet>
<content><![CDATA[
@echo off
cls
SET ERRORLEVEL=0
echo Running go build... ^
& go build -o "${1:${TM_FILEPATH/.+\/(.+)\/.+\..+/$1/}}.exe"^
& if errorlevel 1 goto ERROR
echo Running exe ${1}.exe... ^
& ${1}.exe ^
& if errorlevel 1 goto ERROR
goto SUCCESS
:SUCCESS
echo Success!!
goto EOF
:ERROR
echo ERROR!!! See the last ran command
pause
goto EOF
:EOF
]]></content>
<tabTrigger>run_go_app</tabTrigger>
<scope>source.dosbatch</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment