Documentation ¶
Index ¶
- func Bool(fd protoreflect.FieldDescriptor, opts GenOptions) bool
- func Bytes(fd protoreflect.FieldDescriptor, opts GenOptions) []byte
- func Enum(fd protoreflect.FieldDescriptor, opts GenOptions) protoreflect.EnumNumber
- func Fixed32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
- func Fixed64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
- func Float32(fd protoreflect.FieldDescriptor, opts GenOptions) float32
- func Float64(fd protoreflect.FieldDescriptor, opts GenOptions) float64
- func GoogleDuration(fd protoreflect.FieldDescriptor) *durationpb.Duration
- func GoogleTimestamp(fd protoreflect.FieldDescriptor) *timestamppb.Timestamp
- func GoogleValue(fd protoreflect.FieldDescriptor, opts GenOptions) *structpb.Value
- func Int32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func Int64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func Map(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
- func NewMessage(md protoreflect.MessageDescriptor, opts GenOptions) protoreflect.ProtoMessage
- func Repeated(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
- func SFixed32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func SFixed64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func SInt32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
- func SInt64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
- func SetDataOnMessage(msg protoreflect.ProtoMessage, opts GenOptions)
- func String(fd protoreflect.FieldDescriptor, opts GenOptions) string
- func UInt32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
- func UInt64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
- type GenOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶ added in v0.0.9
func Bool(fd protoreflect.FieldDescriptor, opts GenOptions) bool
Bool returns a fake boolean value given a field descriptor.
func Bytes ¶ added in v0.0.9
func Bytes(fd protoreflect.FieldDescriptor, opts GenOptions) []byte
Bytes returns a fake []byte value given a field descriptor.
func Enum ¶ added in v0.0.9
func Enum(fd protoreflect.FieldDescriptor, opts GenOptions) protoreflect.EnumNumber
Enum returns a fake enum value given a field descriptor.
func Fixed32 ¶ added in v0.0.9
func Fixed32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
Fixed32 returns a fake fixed32 value given a field descriptor.
func Fixed64 ¶ added in v0.0.9
func Fixed64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
Fixed64 returns a fake fixed64 value given a field descriptor.
func Float32 ¶ added in v0.0.9
func Float32(fd protoreflect.FieldDescriptor, opts GenOptions) float32
Float32 returns a fake float32 value given a field descriptor.
func Float64 ¶ added in v0.0.9
func Float64(fd protoreflect.FieldDescriptor, opts GenOptions) float64
Float64 returns a fake float64 value given a field descriptor.
func GoogleDuration ¶ added in v0.0.9
func GoogleDuration(fd protoreflect.FieldDescriptor) *durationpb.Duration
GoogleDuration generates a random google.protobuf.Duration value.
func GoogleTimestamp ¶ added in v0.0.9
func GoogleTimestamp(fd protoreflect.FieldDescriptor) *timestamppb.Timestamp
GoogleTimestamp generates a random google.protobuf.Timestamp value.
func GoogleValue ¶ added in v0.0.9
func GoogleValue(fd protoreflect.FieldDescriptor, opts GenOptions) *structpb.Value
func Int32 ¶ added in v0.0.9
func Int32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
Int32 returns a fake int32 value given a field descriptor.
func Int64 ¶ added in v0.0.9
func Int64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
Int64 returns a fake int64 value given a field descriptor.
func Map ¶ added in v0.0.16
func Map(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
Map returns a fake repeated value given a field descriptor.
func NewMessage ¶ added in v0.0.10
func NewMessage(md protoreflect.MessageDescriptor, opts GenOptions) protoreflect.ProtoMessage
NewMessage creates a new message populated with fake data given a protoreflect.MessageDescriptor
Example ¶
package main import ( "fmt" elizav1 "buf.build/gen/go/connectrpc/eliza/protocolbuffers/go/connectrpc/eliza/v1" "github.com/sudorandom/fauxrpc" "google.golang.org/protobuf/encoding/protojson" ) func main() { msg := fauxrpc.NewMessage(elizav1.File_connectrpc_eliza_v1_eliza_proto.Messages().ByName("SayResponse"), fauxrpc.GenOptions{}) b, _ := protojson.MarshalOptions{Indent: " "}.Marshal(msg) fmt.Println(string(b)) }
Output:
func Repeated ¶ added in v0.0.16
func Repeated(msg protoreflect.Message, fd protoreflect.FieldDescriptor, opts GenOptions) *protoreflect.Value
Repeated returns a fake repeated value given a field descriptor.
func SFixed32 ¶ added in v0.0.9
func SFixed32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
SFixed32 returns a fake sfixedint32 value given a field descriptor.
func SFixed64 ¶ added in v0.0.9
func SFixed64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
SFixed64 returns a fake sfixed64 value given a field descriptor.
func SInt32 ¶ added in v0.0.9
func SInt32(fd protoreflect.FieldDescriptor, opts GenOptions) int32
SInt32 returns a fake sint32 value given a field descriptor.
func SInt64 ¶ added in v0.0.9
func SInt64(fd protoreflect.FieldDescriptor, opts GenOptions) int64
SInt64 returns a fake sint64 value given a field descriptor.
func SetDataOnMessage ¶ added in v0.0.4
func SetDataOnMessage(msg protoreflect.ProtoMessage, opts GenOptions)
SetDataOnMessage generates fake data given a protoreflect.ProtoMessage and sets the field values.
Example ¶
package main import ( "fmt" elizav1 "buf.build/gen/go/connectrpc/eliza/protocolbuffers/go/connectrpc/eliza/v1" "github.com/sudorandom/fauxrpc" "google.golang.org/protobuf/encoding/protojson" ) func main() { msg := &elizav1.SayResponse{} fauxrpc.SetDataOnMessage(msg, fauxrpc.GenOptions{}) b, _ := protojson.MarshalOptions{Indent: " "}.Marshal(msg) fmt.Println(string(b)) }
Output:
func String ¶ added in v0.0.9
func String(fd protoreflect.FieldDescriptor, opts GenOptions) string
String returns a fake string value given a field descriptor.
func UInt32 ¶ added in v0.0.9
func UInt32(fd protoreflect.FieldDescriptor, opts GenOptions) uint32
UInt32 returns a fake uint32 value given a field descriptor.
func UInt64 ¶ added in v0.0.9
func UInt64(fd protoreflect.FieldDescriptor, opts GenOptions) uint64
UInt64 returns a fake uint64 value given a field descriptor.
Types ¶
type GenOptions ¶ added in v0.0.14
type GenOptions struct { StubDB stubs.StubDatabase MaxDepth int // contains filtered or unexported fields }