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

Method Example

expr/types.go:355–382  ·  view source on GitHub ↗

Example generates a pseudo-random primitive value using the given random generator.

(r *ExampleGenerator)

Source from the content-addressed store, hash-verified

353// Example generates a pseudo-random primitive value using the given random
354// generator.
355func (p Primitive) Example(r *ExampleGenerator) any {
356 switch p {
357 case Boolean:
358 return r.Bool()
359 case Int:
360 return r.Int()
361 case Int32:
362 return r.Int32()
363 case Int64:
364 return r.Int64()
365 case UInt:
366 return r.UInt()
367 case UInt32:
368 return r.UInt32()
369 case UInt64:
370 return r.UInt64()
371 case Float32:
372 return r.Float32()
373 case Float64:
374 return r.Float64()
375 case String, Any:
376 return r.String()
377 case Bytes:
378 return []byte(r.String())
379 default:
380 panic("unknown primitive type") // bug
381 }
382}
383
384// Hash returns a unique hash value for p.
385func (p Primitive) Hash() string {

Callers

nothing calls this directly

Calls 10

BoolMethod · 0.65
IntMethod · 0.65
Int32Method · 0.65
Int64Method · 0.65
UIntMethod · 0.65
UInt32Method · 0.65
UInt64Method · 0.65
Float32Method · 0.65
Float64Method · 0.65
StringMethod · 0.65

Tested by

no test coverage detected