-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtype.go
56 lines (44 loc) · 859 Bytes
/
type.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
54
55
56
package gosoap
import (
"errors"
"reflect"
"strings"
"github.com/afocus/gosoap/xsd"
)
func checkBaseTypeKind(k reflect.Kind) (string, error) {
switch k {
case reflect.String:
return xsd.String, nil
case reflect.Int, reflect.Int32:
return xsd.Int32, nil
case reflect.Int64:
return xsd.Int64, nil
case reflect.Bool:
return xsd.Bool, nil
case reflect.Float32:
return xsd.Float32, nil
case reflect.Float64:
return xsd.Float64, nil
default:
return "", errors.New("xxx")
}
}
func getTagsInfo(t reflect.StructField) (string, bool) {
required := false
name := t.Name
tags := strings.Split(t.Tag.Get("wsdl"), ",")
for k, v := range tags {
tag := strings.TrimSpace(v)
if k == 0 {
if tag != "" {
name = tag
}
} else {
if tag == "required" {
required = true
break
}
}
}
return name, required
}