A simple Go library to ping Minecraft Bedrock/MCPE servers.
Install using go get github.com/ZeroErrors/go-bedrockping
package main
import (
"fmt"
"github.com/ZeroErrors/go-bedrockping"
"log"
"time"
)
func main() {
resp, err := bedrockping.Query("myip:19132", 5 * time.Second, 150 * time.Millisecond)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d/%d players are online.", resp.PlayerCount, resp.MaxPlayers)
}
(The default port, 19132, is also available as a const, bedrockping.DefaultPort
.)
The response structure is described in bedrockping.Response