As a language launched by Google in 2009, Go is designed as a system programming language for giant central servers with web servers, storage clusters or similar purposes.
For the field of high-performance distributed systems, Go is undoubtedly more efficient than most other languages. It provides massive parallel support, which is better for game server development.
Go development has been completely open and has an active community.
Let’s see how the golang project is online and deployed to the Linux server.
Windows Server
Compile locally first
go build
After compilation, an executable file will be generated in the same level directory.
Linux Server
Method 1: Compile on the server
Install go and configure GOPATH
1. Configure the same environment as the local area on the server
2. Including the packages that are dependent on in the project
3. Copy the source code of the project to the server and compile it on the server.
go build
After compilation, an executable file will be generated in the same level directory.
main
Finally, just execute ./main.
If you want the project to be executed in the background: execute nohup ./main & , the program can be run in the background
Note: I found that if you only specify the path of GOROOT according to the official installation method, you can create a new directory gopath as the directory of GOPATH and set the environment variable (export GOPATH=/newhome/go/gopath). Create 3 new folders under gopath (imitates Windows GOPATH, which is also the working environment directory of the Go language) into src, pkg, and bin directories respectively
Method 2: Local Compilation
cmd console to file directory
set GOARCH=amd64
set GOOS=linux
go build
A binary file without a suffix will be generated
main
Put the file into a folder in a Linux system
Grant permissions
chmod 777 main
Finally, just execute ./main.
If you want the project to be executed in the background: execute nohup ./main & , the program can be run in the background
This is the article about how to deploy the golang project online to the Linux server (detailed explanation of the method). For more related contents of the golang project online to deploy the Linux server, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!