Skip to content

Commit 467e4b7

Browse files
author
wzh
committed
添加解析值为数组时的判断, 和错误返回原因
1 parent 7ab62fc commit 467e4b7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mms.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ package iec61850
44
import "C"
55
import (
66
"fmt"
7-
"github.com/spf13/cast"
87
"unsafe"
8+
9+
"github.com/spf13/cast"
910
)
1011

1112
func toMmsValue(mmsType MmsType, value interface{}) (*C.MmsValue, error) {
@@ -114,8 +115,8 @@ func toGoValue(mmsValue *C.MmsValue, mmsType MmsType) (interface{}, error) {
114115
}
115116

116117
func toGoStructure(mmsValue *C.MmsValue, mmsType MmsType) ([]*MmsValue, error) {
117-
if mmsType != Structure {
118-
return nil, nil
118+
if !(mmsType == Structure || mmsType == Array) {
119+
return nil, fmt.Errorf("require struct or array type value, but got type code is: %d", mmsType)
119120
}
120121

121122
mmsValues := make([]*MmsValue, 0)

0 commit comments

Comments
 (0)