mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
refactor: use reflect.TypeFor instead of reflect.TypeOf and improve related tests (#2101)
* refactor: using reflect.TypeFor Signed-off-by: suranmiao <solsui@outlook.com> * refactor: remove unused reflect.TypeFor calls and improve test assertions * refactor: simplify TestSetup by removing reflect.TypeFor * test: enhance test assertions and improve parallel execution in TestSetup --------- Signed-off-by: suranmiao <solsui@outlook.com> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -1084,8 +1084,7 @@ func StringToOrderSide(side string) (Side, error) {
|
||||
func (s *Side) UnmarshalJSON(data []byte) (err error) {
|
||||
if !bytes.HasPrefix(data, []byte(`"`)) {
|
||||
// Note that we don't need to worry about invalid JSON here, it wouldn't have made it past the deserialiser far
|
||||
// TODO: Can use reflect.TypeFor[s]() when it's released, probably 1.21
|
||||
return &json.UnmarshalTypeError{Value: string(data), Type: reflect.TypeOf(s), Offset: 1}
|
||||
return &json.UnmarshalTypeError{Value: string(data), Type: reflect.TypeFor[*Side]()}
|
||||
}
|
||||
*s, err = StringToOrderSide(string(data[1 : len(data)-1])) // Remove quotes
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user