mirror of
https://github.com/openobserve/goflow2.git
synced 2025-11-04 22:03:21 +00:00
refactor: v2 (#150)
This commit is contained in:
16
decoders/sflow/format.go
Normal file
16
decoders/sflow/format.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package sflow
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
)
|
||||
|
||||
func (p *Packet) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(*p) // this is a trick to avoid having the JSON marshaller defaults to MarshalText
|
||||
}
|
||||
|
||||
func (p *Packet) MarshalText() ([]byte, error) {
|
||||
agentIP, _ := netip.AddrFromSlice(p.AgentIP)
|
||||
return []byte(fmt.Sprintf("sFlow%d agent:%s seq:%d count:%d", p.Version, agentIP.String(), p.SequenceNumber, p.SamplesCount)), nil
|
||||
}
|
||||
Reference in New Issue
Block a user