code refactor: rename var

This commit is contained in:
Ulric Qin 2022-04-25 11:47:41 +08:00
parent 2ef3cb623c
commit e960033b53
1 changed files with 7 additions and 7 deletions

View File

@ -26,7 +26,7 @@ import (
// }, // },
// ] // ]
type FalconSample struct { type Sample struct {
Endpoint string `json:"endpoint"` Endpoint string `json:"endpoint"`
Metric string `json:"metric"` Metric string `json:"metric"`
Timestamp int64 `json:"timestamp"` Timestamp int64 `json:"timestamp"`
@ -34,14 +34,14 @@ type FalconSample struct {
Tags string `json:"tags"` Tags string `json:"tags"`
} }
type FalconParser struct{} type Parser struct{}
func NewParser() *FalconParser { func NewParser() *Parser {
return &FalconParser{} return &Parser{}
} }
func (p *FalconParser) Parse(input []byte, slist *list.SafeList) error { func (p *Parser) Parse(input []byte, slist *list.SafeList) error {
var samples []FalconSample var samples []Sample
if input[0] == '[' { if input[0] == '[' {
err := json.Unmarshal(input, &samples) err := json.Unmarshal(input, &samples)
@ -49,7 +49,7 @@ func (p *FalconParser) Parse(input []byte, slist *list.SafeList) error {
return err return err
} }
} else { } else {
var s FalconSample var s Sample
err := json.Unmarshal(input, &s) err := json.Unmarshal(input, &s)
if err != nil { if err != nil {
return err return err