Open ghost opened 3 years ago
When I call deepcopy method, i am facing issue. ===================METHOD================== response.BdtReqData = deepcopy.Copy(&request).(*models.BdtReqData)
=====================BdtReqData======================== package models
type BdtReqData struct { AspId string json:"aspId" yaml:"aspId" bson:"aspId" mapstructure:"AspId" DesTimeInt TimeWindow json:"desTimeInt" yaml:"desTimeInt" bson:"desTimeInt" mapstructure:"DesTimeInt" NwAreaInfo NetworkAreaInfo json:"nwAreaInfo,omitempty" yaml:"nwAreaInfo" bson:"nwAreaInfo" mapstructure:"NwAreaInfo" NumOfUes int32 json:"numOfUes" yaml:"numOfUes" bson:"numOfUes" mapstructure:"NumOfUes" VolPerUe *UsageThreshold json:"volPerUe" yaml:"volPerUe" bson:"volPerUe" mapstructure:"VolPerUe" SuppFeat string json:"suppFeat,omitempty" yaml:"suppFeat" bson:"suppFeat" mapstructure:"SuppFeat" }
json:"aspId" yaml:"aspId" bson:"aspId" mapstructure:"AspId"
json:"desTimeInt" yaml:"desTimeInt" bson:"desTimeInt" mapstructure:"DesTimeInt"
json:"nwAreaInfo,omitempty" yaml:"nwAreaInfo" bson:"nwAreaInfo" mapstructure:"NwAreaInfo"
json:"numOfUes" yaml:"numOfUes" bson:"numOfUes" mapstructure:"NumOfUes"
json:"volPerUe" yaml:"volPerUe" bson:"volPerUe" mapstructure:"VolPerUe"
json:"suppFeat,omitempty" yaml:"suppFeat" bson:"suppFeat" mapstructure:"SuppFeat"
==================Request Restful API Call=========================== curl -X 'POST' \ 'http://127.0.0.7:8000/npcf-bdtpolicycontrol/v1/bdtpolicies' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "aspId": "ASP001", "desTimeInt": { "startTime": "2021-09-25T18:07:00.083Z", "stopTime": "2021-09-26T21:09:45.083Z" }, "numOfUes": 3, "volPerUe": { "duration": 360, "totalVolume": 1024, "downlinkVolume": 512, "uplinkVolume": 512 } }' ================Error============================= 2021/09/29 10:10:34 [Recovery] 2021/09/29 - 10:10:34 panic recovered: interface conversion: interface {} is *models.BdtReqData, not models.BdtReqData /usr/local/go/src/runtime/iface.go:260 (0x409b71) panicdottypeE: panic(&TypeAssertionError{iface, have, want, ""})
Please submit a reduced test case.
maybe your request already is pointer
When I call deepcopy method, i am facing issue. ===================METHOD================== response.BdtReqData = deepcopy.Copy(&request).(*models.BdtReqData)
=====================BdtReqData======================== package models
type BdtReqData struct { AspId string
json:"aspId" yaml:"aspId" bson:"aspId" mapstructure:"AspId"
DesTimeInt TimeWindowjson:"desTimeInt" yaml:"desTimeInt" bson:"desTimeInt" mapstructure:"DesTimeInt"
NwAreaInfo NetworkAreaInfojson:"nwAreaInfo,omitempty" yaml:"nwAreaInfo" bson:"nwAreaInfo" mapstructure:"NwAreaInfo"
NumOfUes int32json:"numOfUes" yaml:"numOfUes" bson:"numOfUes" mapstructure:"NumOfUes"
VolPerUe *UsageThresholdjson:"volPerUe" yaml:"volPerUe" bson:"volPerUe" mapstructure:"VolPerUe"
SuppFeat stringjson:"suppFeat,omitempty" yaml:"suppFeat" bson:"suppFeat" mapstructure:"SuppFeat"
}==================Request Restful API Call=========================== curl -X 'POST' \ 'http://127.0.0.7:8000/npcf-bdtpolicycontrol/v1/bdtpolicies' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "aspId": "ASP001", "desTimeInt": { "startTime": "2021-09-25T18:07:00.083Z", "stopTime": "2021-09-26T21:09:45.083Z" }, "numOfUes": 3, "volPerUe": { "duration": 360, "totalVolume": 1024, "downlinkVolume": 512, "uplinkVolume": 512 } }' ================Error============================= 2021/09/29 10:10:34 [Recovery] 2021/09/29 - 10:10:34 panic recovered: interface conversion: interface {} is *models.BdtReqData, not models.BdtReqData /usr/local/go/src/runtime/iface.go:260 (0x409b71) panicdottypeE: panic(&TypeAssertionError{iface, have, want, ""})