package cmds import ( "fmt" "inp2025/tcp" "github.com/spf13/cobra" ) func ping() { msgs := []string{"hello, world", "goodbye"} for _, msg := range msgs { fmt.Printf("client sending: '%s'\n", msg) b, err := tcp.Post(":8080", "/", []byte(msg)) if err != nil { panic(err) } fmt.Printf("server reply: '%s'\n", string(b)) } } func pull() { socket, err := tcp.Dial(":8080", "/") if err != nil { panic(err) } defer socket.Shutdown() for i := 0; i < 5; i++ { b, err := socket.Read() if err != nil { panic(err) } fmt.Printf("server send: '%s'\n", string(b)) } } var clientCmd = &cobra.Command{ Use: "client", Run: func(cmd *cobra.Command, args []string) { pull() }, }