One-click Compile go File command. bat

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.