MCPcopy Create free account
hub / github.com/goadesign/goa / MakeSlice

Method MakeSlice

expr/types.go:436–442  ·  view source on GitHub ↗

MakeSlice examines the key type from the Array and create a slice with builtin type if possible. The idea is to avoid generating []any and produce more precise types.

(s []any)

Source from the content-addressed store, hash-verified

434// builtin type if possible. The idea is to avoid generating []any and
435// produce more precise types.
436func (a *Array) MakeSlice(s []any) any {
437 slice := reflect.MakeSlice(toReflectType(a), 0, len(s))
438 for _, item := range s {
439 slice = reflect.Append(slice, reflect.ValueOf(item))
440 }
441 return slice.Interface()
442}
443
444// ToSlice converts an ArrayVal into a slice.
445func (a ArrayVal) ToSlice() []any {

Callers 2

ExampleMethod · 0.95
byLengthFunction · 0.80

Calls 2

toReflectTypeFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected