You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
595 B
Go

package main
import (
"fmt"
"github.com/iverly/go-mcping/mcping"
)
func pingMinecraft(ip string) {
// Create a new Pinger instance
pinger := mcping.NewPinger()
// Ping the Minecraft server
response, err := pinger.Ping(ip, 25565)
if err != nil {
fmt.Println("Failed to ping server: %v\n", err)
return
}
// Print server information
fmt.Println("Server Version: %s\n", response.Version)
fmt.Println("Players Online: %d / %d\n", response.PlayerCount.Online, response.PlayerCount.Max)
fmt.Println("MOTD: %s\n", response.Motd)
fmt.Println("Latency: %d ms\n", response.Latency)
}