我正在使用 github.com/bwmarrin/discordgo包裹 我在示例中看到保持连接或“ session ”事件的方法是使用以下内容:
<-make(chan struct{})
但它看起来有点乱,这是保持它存活的最好方法还是有其他方法。
最佳答案
您没有提供指向示例的链接,所以我们只能猜测。例如,我的猜测,
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
你试过吗?
The Go Programming Language Specification
select {} // block forever
关于go - 在 discordgo 中保持连接/ session 事件的更简洁方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57240085/