MCPcopy Create free account
hub / github.com/coze-dev/coze-go / reflectToQueryString

Function reflectToQueryString

request.go:643–664  ·  view source on GitHub ↗
(v reflect.Value)

Source from the content-addressed store, hash-verified

641}
642
643func reflectToQueryString(v reflect.Value) (s []string) {
644 if v.Kind() == reflect.Ptr {
645 v = v.Elem()
646 }
647 switch v.Kind() {
648 case reflect.String:
649 return []string{v.String()}
650 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
651 return []string{strconv.FormatInt(v.Int(), 10)}
652 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
653 return []string{strconv.FormatUint(v.Uint(), 10)}
654 case reflect.Bool:
655 return []string{strconv.FormatBool(v.Bool())}
656 case reflect.Slice, reflect.Array:
657 for i := 0; i < v.Len(); i++ {
658 s = append(s, reflectToString(v.Index(i)))
659 }
660 return s
661 default:
662 return []string{v.String()}
663 }
664}
665
666func isInReflectKind(v reflect.Kind, list []reflect.Kind) bool {
667 for _, vv := range list {

Callers 1

Calls 2

reflectToStringFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected