reorder payload type check in udp client

This commit is contained in:
Joel Wetzell
2025-11-25 11:16:58 -06:00
parent b3815c4a22
commit 3b86690c58

View File

@@ -76,6 +76,11 @@ func (uc *UDPClient) Run() error {
func (uc *UDPClient) Output(payload any) error {
payloadBytes, ok := payload.([]byte)
if !ok {
return fmt.Errorf("net.udp.client is only able to output bytes")
}
client, err := net.DialUDP("udp", nil, uc.addr)
if err != nil {
return err
@@ -83,11 +88,6 @@ func (uc *UDPClient) Output(payload any) error {
uc.conn = client
payloadBytes, ok := payload.([]byte)
if !ok {
return fmt.Errorf("net.udp.client is only able to output bytes")
}
_, err = uc.conn.Write(payloadBytes)
if err != nil {