MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / AppendToSlice

Function AppendToSlice

options/options.go:108–120  ·  view source on GitHub ↗

AppendToSlice appends a value to a slice option. If the option does not exist, it creates a new slice with the value.

(o *Options, key string, value ...T)

Source from the content-addressed store, hash-verified

106// AppendToSlice appends a value to a slice option.
107// If the option does not exist, it creates a new slice with the value.
108func AppendToSlice[T any](o *Options, key string, value ...T) {
109 if v, ok := o.m[key]; ok {
110 vt, ok := v.([]T)
111 if !ok {
112 panic(newTypeMismatchError(key, v, new([]T)))
113 }
114
115 o.m[key] = append(vt, value...)
116 return
117 }
118
119 o.m[key] = append([]T(nil), value...)
120}
121
122// SliceContains checks if a slice option contains a specific value.
123// If the option does not exist, it returns false.

Callers 3

TestAppendToSliceMethod · 0.92
applyPresetOptionMethod · 0.92

Calls 1

newTypeMismatchErrorFunction · 0.85

Tested by 1

TestAppendToSliceMethod · 0.74