This is a creation in Article, where the information may have evolved or changed.
One-click Compile go File command. bat, please create a new button to compile the Go File command. bat files, put them in your xxx.go file directory
(Welcome to the Go language group: 218160862, there is practice in the group)
@echooff:: Gets the name of the directory used for the start directory name of the. exeSetDirname=Gotogetdirname:: Delete process file Taskkill/f/fi"IMAGENAME eq%dirname%.exe">nul:: Start these 2 services to avoid EXE file delay of 1 minutes to remove application experience and Program Compatibility Assistant service for/F"skip=3 tokens=4"%%iinch('sc query aelookupsvc ') do set "zt=%%i"if/I"%zt%"=="RUNNING"(Echo.)Else(net start"aelookupsvc" ) for/F"skip=3 tokens=4"%%iinch('sc query pcasvc ') do set "zt=%%i"if/I"%zt%"=="RUNNING"(Echo.)Else(net start"pcasvc"):: delete old exe-compiled filesifExist%dirname%.exe (del%dirname%.exe) >nul:: Execute Build_go_app subroutine: Modify the GOPATH environment variable, compile the Go program as EXE, start compiling EXE programGotoBuild_go_app:: No Entry required:%_curdisk% &(CD%_curpath%):: Get the name of the directory: GetdirnameSet "lj=%~p0" Set "lj=%lj:\=%" for%%ainch(%lj%) Do Setwjj=%%aSetDirname=%wjj%:: Compile Go Program: Build_go_app Echo. echo "Start compiling go program for EXE executable"::: Execute go to compile go build-ldflags="- H Windowsgui"-gcflags="-n-l"Echo has executed the compile command: Go build-ldflags="- H Windowsgui"-gcflags="-n-l":: Delete Debug Symbols: Go build-ldflags "-s-w"-S: Removes symbolic information. -w: Remove dwarf debug information. :: Close inline optimization: Go build-gcflags "-N-L "Echo. Echo. Echo. :: Starts the compiled program. Success, delay 2 seconds disappear, failure, no vanishing pauseifexist%dirname%.exe (choice/t1/d y/n >nul) | (Echo OK, compile successfully!) Opening program) & (Start%dirname%.exe))Else(Echo compilation failed!| pause) echo. Echo.
(Welcome to the Go language group: 218160862, there is practice in the group)