-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen_gas_json.go
53 lines (49 loc) · 1.34 KB
/
gen_gas_json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package inference
import (
"encoding/json"
"errors"
)
// MarshalJSON marshals as JSON.
func (g GasWork) MarshalJSON() ([]byte, error) {
type GasWork struct {
Type InferType `json:"type" gencodec:"required"`
Model string `json:"model" gencodec:"required"`
ModelSize uint64 `json:"modelSize"`
CvmNetworkId int64 `json:"cvm_networkid"`
}
var enc GasWork
enc.Type = g.Type
enc.Model = g.Model
enc.ModelSize = g.ModelSize
enc.CvmNetworkId = g.CvmNetworkId
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (g *GasWork) UnmarshalJSON(input []byte) error {
type GasWork struct {
Type *InferType `json:"type" gencodec:"required"`
Model *string `json:"model" gencodec:"required"`
ModelSize *uint64 `json:"modelSize"`
CvmNetworkId *int64 `json:"cvm_networkid"`
}
var dec GasWork
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Type == nil {
return errors.New("missing required field 'type' for GasWork")
}
g.Type = *dec.Type
if dec.Model == nil {
return errors.New("missing required field 'model' for GasWork")
}
g.Model = *dec.Model
if dec.ModelSize != nil {
g.ModelSize = *dec.ModelSize
}
if dec.CvmNetworkId != nil {
g.CvmNetworkId = *dec.CvmNetworkId
}
return nil
}