Go Project
Go projects are used to deploy backend applications developed with Go language, such as Gin, Echo, Fiber frameworks.
Prerequisites
- Install Go runtime environment: Applications > Runtime Environment > Go
- Compiled Go executable file or source code
Deployment Methods
Method 1: Deploy Compiled Binary File
- Compile Go project locally:
bash
# Cross-compile for Linux amd64
GOOS=linux GOARCH=amd64 go build -o myapp- Upload binary file to server
- Create project, fill in start command:
./myapp
Method 2: Compile on Server
- Upload source code to server
- Compile in terminal:
bash
cd /opt/ace/project/myapp
go build -o myapp- Create project, fill in start command:
./myapp
Create Go Project
- Go to the Project page
- Click Create Project
- Fill in configuration:
- Project Name:
myapp - Project Directory:
/opt/ace/project/myapp - Start Command:
./myapporgo1.24 run main.go
- Project Name:
- Enable Reverse Proxy for external access
Start Command Examples
bash
# Run compiled binary file
./myapp
# Run with specified Go version
go1.24 run main.go
# Run with parameters
./myapp -port 8080 -config ./config.yaml
# Set environment variables
GIN_MODE=release ./myappCommon Frameworks
Gin
go
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "Hello"})
})
r.Run(":8080")
}Start command: GIN_MODE=release ./myapp
Echo
go
package main
import (
"github.com/labstack/echo/v4"
)
func main() {
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(200, "Hello")
})
e.Start(":8080")
}Fiber
go
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello")
})
app.Listen(":8080")
}Notes
- Ensure binary file has execute permission:
chmod +x myapp - Production environments are recommended to use compiled binary files, not
go run - It is recommended to use environment variables or configuration files to manage configuration, avoid hardcoding
