Recently, I started to contact go language again and wrote an EXE executable program. However, such a console window will appear every time I execute it, and there is no content yet. It’s not elegant, of course.
We can solve this problem by setting compilation parameters in go build
go build -ldflags "-s -w -H=windowsgui"
-s Omit the symbol table and debug information
-w Omit the DWARF symbol table Omit the DWARF symbol table
-H windowsgui does not print messages to the console (On Windows, -H windowsgui writes a "GUI binary" instead of a "console binary."), so there is no cmd window
In this way, the EXE program generated by go compilation can run in the background.
Read More:
- When vs2017 compiles CUDA project, “error msb6006:“ cmd.exe ”Exited with code 1 Solutions for
- After installing CodeBlocks, run the prompt: tried to run compiler executable ‘C: / / MinGW / bin / mingw32- gcc.exe ‘, but failed!
- Windows 7 system, start to run input CMD, the window flashed by, disappeared
- When installing mysql, an error occurs when executing the installation command with the CMD window. Install / Remove of the Service denied
- Vitis: platform out of date, makefile error at compile time; The modified application compiles to undefined reference
- codeblocks error Tried to Run compiler executable ‘C:\MinGW/bin/mingw32-gcc.exe’,but fail
- Go run error go run: cannot run non main package
- When using exe4j to generate exe executable file from jar, no JVM could be found on your system exception appears
- [Android] using request window feature( Window.FEATURE_ NO_ Title) method to remove the title invalid solution
- How to remove the title bar (using the request window feature)( Window.FEATURE_ NO_ Title); why it fails)
- Python packaged *. Exe is running os.popen (cmd)/ subprocess.Popen *. Exe crashes with invalid [winerror 6] handle
- Solution to the problem of console output window’s CMD flashing back when vs2015 writes C + + program
- Vs compilation error msb6006:“ cmd.exe ” exited with code 1.
- Kill the specified port CMD command line taskkill in window
- error MSB6006: cmd.exe “exited with code 3
- Computer CMD window net view command 6118 error resolution
- After Oracle 11g is installed, SQL_ Plus.exe The problem of Chinese garbled in command window
- Compiling QT project under vs encountered “error 89error msb6006:“ cmd.exe ”Exited with code 3
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Solution to prompt run time error “438” when a VB program is opened