I'm using the github.com/bwmarrin/discordgo package and I've seen in the examples that the way to keep a connection or a "session" alive is to use the following:
<-make(chan struct{})
But it looks kinda messy, is this the best way of keeping it alive or is there another method.
You didn't provide a link to your example, so we can only guess. For example, my guess,
the last bit of code in our main function:
<-make(chan struct{})
We're creating a channel that takes an empty struct that waits for input. This is a SUPER hacky way of making our main function sit and wait forever while not using any CPU.
https://boostlog.io/@cuken/writing-a-simple-discord-bot-in-go-part-1-5ae6a1d647018500491f42bb
Have you tried this?
The Go Programming Language Specification
select {} // block forever