Deploy GO application on Google Compute Engine

less than 1 minute read

Hello There!

Create Instance

Generate and Add SSH key

Connect app with Filezilla & Putty

Install Go


export $GOPATH=/var/www export $GOROOT=/usr/local/go

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Upload Code

Set firewall rule for 8081

gcloud compute firewall-rules create default-allow-http-8081 –allow tcp:8081 –source-ranges –target-tags http-server –description “Allow port 8081 access to http-server”

Create Service

create /etc/systemd/system/myservice.service

[Unit] Description=my amazing service

[Service] Restart=always RestartSec=3 WorkingDirectory=/var/www/src/ ExecStart=/var/www/src/


enable service

systemctl enable myservice


sudo systemctl start myservice sudo systemctl stop myservice sudo systemctl status myservice sudo systemctl restart myservice

Install Openssl


with password

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj ‘/CN=localhost’

W/o password

openssl req -nodes -new -x509 -keyout server.key -out server.cert

Quick cmd

/var/www/src/ /etc/