MCPcopy
hub / github.com/go-gorm/gorm / ToStringKey

Function ToStringKey

utils/utils.go:86–111  ·  view source on GitHub ↗
(values ...interface{})

Source from the content-addressed store, hash-verified

84}
85
86func ToStringKey(values ...interface{}) string {
87 results := make([]string, len(values))
88
89 for idx, value := range values {
90 if valuer, ok := value.(driver.Valuer); ok {
91 value, _ = valuer.Value()
92 }
93
94 switch v := value.(type) {
95 case string:
96 results[idx] = v
97 case []byte:
98 results[idx] = string(v)
99 case uint:
100 results[idx] = strconv.FormatUint(uint64(v), 10)
101 default:
102 results[idx] = "nil"
103 vv := reflect.ValueOf(v)
104 if vv.IsValid() && !vv.IsZero() {
105 results[idx] = fmt.Sprint(reflect.Indirect(vv).Interface())
106 }
107 }
108 }
109
110 return strings.Join(results, "_")
111}
112
113func Contains(elems []string, elem string) bool {
114 for _, e := range elems {

Callers 6

DeleteMethod · 0.92
SaveBeforeAssociationsFunction · 0.92
SaveAfterAssociationsFunction · 0.92
preloadFunction · 0.92
TestToStringKeyFunction · 0.85

Calls 1

ValueMethod · 0.65

Tested by 1

TestToStringKeyFunction · 0.68