chore: stabilize lint and verify builds
This commit is contained in:
@@ -25,17 +25,19 @@ type ordersSnapshotWire struct {
|
||||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
func (s *OrdersSnapshot) UnmarshalJSON(b []byte) error {
|
||||
var w ordersSnapshotWire
|
||||
if err := json.Unmarshal(b, &w); err == nil && (w.Kind != "" || w.Data != nil) {
|
||||
s.Kind = w.Kind
|
||||
s.Data = w.Data
|
||||
func (snapshot *OrdersSnapshot) UnmarshalJSON(raw []byte) error {
|
||||
var wire ordersSnapshotWire
|
||||
if err := json.Unmarshal(raw, &wire); err == nil && (wire.Kind != "" || wire.Data != nil) {
|
||||
snapshot.Kind = wire.Kind
|
||||
snapshot.Data = wire.Data
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 兼容旧结构:旧 snapshot 通常是一个扁平对象(没有 kind/data)。
|
||||
s.Kind = "legacy"
|
||||
s.Data = append(s.Data[:0], b...)
|
||||
snapshot.Kind = "legacy"
|
||||
snapshot.Data = append(snapshot.Data[:0], raw...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user