39 lines
669 B
Go
39 lines
669 B
Go
package main
|
|
|
|
import (
|
|
"gitea.konchin.com/ytshih/inp2025/utils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var testCmd = &cobra.Command{
|
|
Use: "test",
|
|
}
|
|
|
|
var testServerCmd = &cobra.Command{
|
|
Use: "server",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
dataCh := make(chan string)
|
|
_, shutdown, err := utils.ListenUDPData(18787, dataCh)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer shutdown()
|
|
<-dataCh
|
|
},
|
|
}
|
|
|
|
var testClientCmd = &cobra.Command{
|
|
Use: "client",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
err := utils.Ping("localhost:18787")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
testCmd.AddCommand(testServerCmd)
|
|
testCmd.AddCommand(testClientCmd)
|
|
}
|