MCPcopy Create free account
hub / github.com/devspace-sh/devspace / set

Function set

pkg/util/strvals/strvals.go:249–266  ·  view source on GitHub ↗
(data map[string]interface{}, key string, val interface{})

Source from the content-addressed store, hash-verified

247}
248
249func set(data map[string]interface{}, key string, val interface{}) {
250 // If key is empty, don't set it.
251 if len(key) == 0 {
252 return
253 }
254
255 rt := reflect.TypeOf(val)
256 switch rt.Kind() {
257 case reflect.String:
258 if len(val.(string)) < 1 {
259 data[key] = nil
260 } else {
261 data[key] = val
262 }
263 default:
264 data[key] = val
265 }
266}
267
268func setIndex(list []interface{}, index int, val interface{}) (l2 []interface{}, err error) {
269 // There are possible index values that are out of range on a target system

Callers 1

keyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected