MCPcopy Index your code
hub / github.com/coder/coder / derefPointer

Function derefPointer

enterprise/audit/diff.go:234–249  ·  view source on GitHub ↗

derefPointer deferences a reflect.Value that is a pointer to its underlying value. It dereferences recursively until it finds a non-pointer value. If the pointer is nil, it will be coerced to the zero value of the underlying type.

(ref reflect.Value)

Source from the content-addressed store, hash-verified

232// value. It dereferences recursively until it finds a non-pointer value. If the
233// pointer is nil, it will be coerced to the zero value of the underlying type.
234func derefPointer(ref reflect.Value) reflect.Value {
235 if !ref.IsNil() {
236 // Grab the value the pointer references.
237 ref = ref.Elem()
238 } else {
239 // Coerce nil ptrs to zero'd values of their underlying type.
240 ref = reflect.Zero(ref.Type().Elem())
241 }
242
243 // Recursively deref nested pointers.
244 if ref.Kind() == reflect.Ptr {
245 return derefPointer(ref)
246 }
247
248 return ref
249}

Callers 2

diffValuesFunction · 0.85
flattenStructFieldsFunction · 0.85

Calls 1

TypeMethod · 0.65

Tested by

no test coverage detected