Deploying a Go Application to an ECS Instance
In the previous article, we have discussed how to deploy a local Java application directly to an Alibaba Cloud ECS instance. In this article, we will introduce how to deploy a Go application to an Alibaba Cloud Elastic Compute Service (ECS) instance.
Develop an Application Locally
The coding method is similar no matter whether you compile Go applications that run on the cloud or locally. Therefore, this article takes a Go application for printing "Hello World" on a Web page as an example to explain the deployment method.

//Alibaba Cloud Toolkit. http://www.aliyun.com/product/cloudtoolkit
func setupRouter() *gin.Engine {
// Disable Console Color
// gin.DisableConsoleColor()
r := gin.Default()
// Ping test
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "Alibaba Cloud Toolkit: Hello World.")
})
return r
}
func main() {
r := setupRouter()
// Listen and Server in 0.0.0.0:8080
r.Run(":80")
}
You can download the source code through this link.
The preceding code is a standard Go project used to print the string "Hello World" on a Web page.
Install Plug-in
Alibaba Cloud provides an Eclipse-based plug-in to help developers efficiently deploy applications written in the local IDE to ECS instances.
URL of the plug-in: https://www.aliyun.com/product/cloudtoolkit_en
The installation process of this Eclipse-based plug-in is similar to that of a common plug-in, and therefore will not be detailed here.
Configure the Plug-in Preferences
After installing the plug-in, configure the preferences by choosing:
Top menu > Window > Preferences > Alibaba Cloud Toolkit > Accounts.
When the following page is displayed, configure the AK and SK of your Alibaba Cloud account to complete the configuration of preferences.( If you are using a RAM user account, enter the AK and SK of the RAM user.)

Deploy the Application

In Eclipse, right-click the project name and choose Alibaba Cloud > Deploy to ECS from the shortcut menu. The following deployment window is displayed:

In the Deployment Configurations dialog box, set the deployment parameters, and click Deploy to complete the initial deployment.
Description of Deployment Parameters
- Deploy File: Two options are available.
- Maven Build: If Maven is used to build the current project, you can use Alibaba Cloud Toolkit to directly build and deploy the application.
- Upload File: If Maven is not used to build the current project, or a locally packaged deployment file already exists, you can select and directly upload the local deployment file.
- Target Deploy ECS: Select a region from the drop-down list, and then select the ECS instance to be deployed in the region.
- Deploy location: Enter the deployment path on the ECS instance, for example, /root/tomcat/webapps.
- Command: Enter the application startup command, for example, sh /root/restart.sh. This parameter specifies the command to be executed after the application package is deployed. For a Go program, it is usually a series of program startup commands.
source ~/.bash_profile
pkill -f 'go-demo'
mv /tmp/go-demo /root/go-demo
chmod 755 /root/go-demo
sh -c /root/go-demo
Read previous post:
Deploying a Java Application to an ECS Instance in IntelliJ IDEA
Read next post:
Deploying an Application to Container Service for Kubernetes
Comments
Related Products
-
Robotic Process Automation (RPA)
Robotic Process Automation (RPA) allows you to automate repetitive tasks and integrate business rules and decisions into processes.
Learn More -
EDAS
A PaaS platform for a variety of application deployment options and microservices solutions to help you monitor, diagnose, operate and maintain your applications
Learn More -
Super App Solution for Telcos
Alibaba Cloud (in partnership with Whale Cloud) helps telcos build an all-in-one telecommunication and digital lifestyle platform based on DingTalk.
Learn More -
Alibaba Cloud for Manufacturing
Gain an industrial edge with Alibaba Cloud best practices
Learn More
More Posts by Nick(倪超)
- Deploy Spring Boot or Spring Cloud Applications to Alibaba Cloud in Eclipse
- Alibaba Cloud Toolkit Command Writing Guide
- Deploying Applications to EDAS with Cloud Toolkit Maven Plug-in
- Deploying a Node.js Application to an ECS Instance
- Deploying an Application to Container Service for Kubernetes
- Deploying a Java Application to an ECS Instance in IntelliJ IDEA
- Deploy an Application to Alibaba Cloud EDAS in Eclipse
- Deploying a Java Application to an ECS Instance in Eclipse