Documentation
¶
Index ¶
- func FormatFieldValue(identFunc IdentFunc, field *protogen.Field, value protoreflect.Value) (string, error)
- func FormatMessageField(identFunc IdentFunc, ident protogen.GoIdent, fieldsByNumber FieldsByNumber, ...) (string, error)
- func IsErrorCodeValid(errorCode string) bool
- func MakeExportedName(name string) string
- func ReadContractFile(filePath string) (entities.Contract, error)
- type FieldsByNumber
- type IdentFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatFieldValue ¶
func FormatFieldValue( identFunc IdentFunc, field *protogen.Field, value protoreflect.Value, ) (string, error)
FormatFieldValue receives a value (protoreflect.Value) and converts it to a string format as an instantiate representation. See the example below:
If value is a string the format will be myString -> "myString" because using double quote is the way we use to instantiate/create a string. Some other examples:
- int64: 64 -> 64 (to instantiate/create a int we just need the number)
- []bytes: []byte("abcd") -> []byte{0x61, 0x62, 0x63, 0x64}
func FormatMessageField ¶
func FormatMessageField( identFunc IdentFunc, ident protogen.GoIdent, fieldsByNumber FieldsByNumber, message protoreflect.Message, ) (string, error)
FormatMessageField takes care of formatting a message to a properly string format.
func IsErrorCodeValid ¶
IsErrorCodeValid returns true when a error code exists in the GRPC Codes package
func MakeExportedName ¶
MakeExportedName transforms any string in a Go's exported name. In Go to make a function/struct/const/var public the first letter must be upper.
Types ¶
type FieldsByNumber ¶
type FieldsByNumber map[protoreflect.FieldNumber]*protogen.Field
FieldsByNumber represents the relation between the proto field number with a protogen.Field. It's very useful to correlate with fields from protoreflect.Message.
func CreateFieldsByNumber ¶
func CreateFieldsByNumber(fields []*protogen.Field) FieldsByNumber
CreateFieldsByNumber transform a slice of protogen.Field into a FieldsByNumber, so we can access the field by its number. This is very handy when we need to correlate fields from a protogen.Message with fields from a protoreflect.Message.