MCPcopy Create free account
hub / github.com/pace/bricks / assignValue

Function assignValue

http/jsonapi/request.go:369–386  ·  view source on GitHub ↗

assign assigns the specified value to the field, expecting both values not to be pointer types.

(field, value reflect.Value)

Source from the content-addressed store, hash-verified

367// assign assigns the specified value to the field,
368// expecting both values not to be pointer types.
369func assignValue(field, value reflect.Value) {
370 switch field.Kind() {
371 case reflect.Int, reflect.Int8, reflect.Int16,
372 reflect.Int32, reflect.Int64:
373 field.SetInt(value.Int())
374 case reflect.Uint, reflect.Uint8, reflect.Uint16,
375 reflect.Uint32, reflect.Uint64, reflect.Uintptr:
376 field.SetUint(value.Uint())
377 case reflect.Float32, reflect.Float64:
378 field.SetFloat(value.Float())
379 case reflect.String:
380 field.SetString(value.String())
381 case reflect.Bool:
382 field.SetBool(value.Bool())
383 default:
384 field.Set(value)
385 }
386}
387
388func unmarshalAttribute(
389 rawAttribute json.RawMessage,

Callers 1

assignFunction · 0.85

Calls 2

SetMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…