Home > Backend Development > Golang > How Golang is packaged and deployed on Linux

How Golang is packaged and deployed on Linux

angryTom
Release: 2020-03-14 15:20:53
Original
9012 people have browsed it

How Golang is packaged and deployed on Linux

How to package and deploy Golang on Linux

1. Compile Golang program locally

cmd Go to the main.go file directory in the console and execute:

set GOARCH=amd64
set GOOS=linux
go build main.go
Copy after login

At this time, a binary file without a suffix will be generated

main
Copy after login

2. Upload the Golang binary file to the Linux server

Put the file into a folder in the linux system

Give permissions

chmod 777 main
Copy after login

Finally execute ./main .

If you want the project to execute in the background: execute nohup ./main & , so that the program can run in the background.

For more golang knowledge, please pay attention to the golang tutorial column on the PHP Chinese website.

The above is the detailed content of How Golang is packaged and deployed on Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to choose golang web mvc framework
From 1970-01-01 08:00:00
0
0
0
Is it necessary to use nginx when using golang?
From 1970-01-01 08:00:00
0
0
0
golang - vim plug-in to write go
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template