Go
Complete guide to host Go applications on Discloud.
📁 Preparing the Files
❌ Files to Exclude
- bin/
- *.exe
- .git/🌐 Hosting Websites & APIs in Go
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()
}✍️ Deploying Your Application
Last updated