Go
Complete guide to host Go applications on Discloud.
📁 Preparing the Files
Before uploading your project, you must exclude unnecessary files to optimize the deployment.
❌ Files to Exclude
Ensure the following files and directories are not included in your .zip
:
- bin/
- *.exe
- .git/
📌 Use a .discloudignore
file to automatically exclude these files. Do not exclude go.mod
or go.sum
.
🔗 Need help setting up your go.mod
or find main file?
🌐 Hosting Websites & APIs in Go
Before deploying your website or API on Discloud, ensure that you meet the following requirements:
Platinum plan or higher is required to host websites or APIs.
A subdomain must be created before deployment.
Port 8080
is mandatory – Applications must listen on this port.
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/bwmarrin/discordgo"
)
func main() {
token := os.Getenv("DISCORD_TOKEN")
if token == "" { log.Fatal("DISCORD_TOKEN not set") }
dg, err := discordgo.New("Bot " + token)
if err != nil { log.Fatal(err) }
dg.AddHandler(func(s *discordgo.Session, r *discordgo.Ready) {
log.Println("Bot is ready")
})
if err := dg.Open(); err != nil { log.Fatal(err) }
log.Println("Bot running. Press CTRL+C to exit.")
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
<-stop
dg.Close()
}
Bots do not need to bind any HTTP port. They just have to keep the process alive.
✍️ Deploying Your Application
Once your project is configured and compressed, you can choose one of the following deployment methods on Discloud:
Last updated