Documentation
¶
Index ¶
- Variables
- func FormatProtoEnum(typ *sppb.Type, mode ProtoEnumMode) string
- func FormatStructFields(fields []*sppb.StructType_Field, opts FormatOption) string
- func FormatType(typ *sppb.Type, opts FormatOption) string
- func FormatTypeCode(code sppb.TypeCode, mode UnknownMode) string
- func FormatTypeMoreVerbose(typ *sppb.Type) string
- func FormatTypeNormal(typ *sppb.Type) string
- func FormatTypeSimple(typ *sppb.Type) string
- func FormatTypeSimplest(typ *sppb.Type) string
- func FormatTypeVerbose(typ *sppb.Type) string
- type ArrayMode
- type FormatOption
- type ProtoEnumMode
- type StructMode
- type UnknownMode
Constants ¶
This section is empty.
Variables ¶
var ( // FormatOptionSimplest is a FormatOption for FormatTypeSimplest. FormatOptionSimplest = FormatOption{ Struct: StructModeBase, Proto: ProtoEnumModeBase, Enum: ProtoEnumModeBase, Array: ArrayModeBase, Unknown: UnknownModeTypeCode, } // FormatOptionSimple is a FormatOption for FormatTypeSimple. FormatOptionSimple = FormatOption{ Struct: StructModeBase, Proto: ProtoEnumModeLeaf, Enum: ProtoEnumModeLeaf, Array: ArrayModeRecursive, Unknown: UnknownModeUnknown, } // FormatOptionNormal is a FormatOption for FormatTypeNormal. FormatOptionNormal = FormatOption{ Struct: StructModeRecursive, Proto: ProtoEnumModeLeaf, Enum: ProtoEnumModeLeaf, Array: ArrayModeRecursive, Unknown: UnknownModeVerbose, } // FormatOptionVerbose is a FormatOption for FormatTypeVerbose. FormatOptionVerbose = FormatOption{ Struct: StructModeRecursiveWithName, Proto: ProtoEnumModeFull, Enum: ProtoEnumModeFull, Array: ArrayModeRecursive, Unknown: UnknownModeVerbose, } // FormatOptionMoreVerbose is a FormatOption for FormatTypeMoreVerbose. FormatOptionMoreVerbose = FormatOption{ Struct: StructModeRecursiveWithName, Proto: ProtoEnumModeFullWithKind, Enum: ProtoEnumModeFullWithKind, Array: ArrayModeRecursive, Unknown: UnknownModeVerbose, } )
Functions ¶
func FormatProtoEnum ¶ added in v0.2.0
func FormatProtoEnum(typ *sppb.Type, mode ProtoEnumMode) string
FormatProtoEnum formats `PROTO` or `ENUM` type using ProtoEnumMode. It panics when the input type is not `PROTO` or `ENUM`.
func FormatStructFields ¶
func FormatStructFields(fields []*sppb.StructType_Field, opts FormatOption) string
FormatStructFields formats Cloud Spanner struct fields or `metadata.rowType` using the given FormatOption.
func FormatType ¶
func FormatType(typ *sppb.Type, opts FormatOption) string
FormatType formats Cloud Spanner type using the given FormatOption.
func FormatTypeCode ¶ added in v0.2.0
func FormatTypeCode(code sppb.TypeCode, mode UnknownMode) string
FormatTypeCode formats sppb.TypeCode, but it formats unknown type code as `UNKNOWN(int32(code))`. e.g. `UNKNOWN(-1)`
func FormatTypeMoreVerbose ¶ added in v0.3.0
FormatTypeMoreVerbose formats Cloud Spanner type as more verbose format. e.g. `INT64`, `ARRAY<INT64>`, `PROTO<examples.ProtoType>`, `ENUM<examples.EnumType>`, `STRUCT<n INT64>`
func FormatTypeNormal ¶
FormatTypeNormal formats Cloud Spanner type as normal format. e.g. `INT64`, `ARRAY<INT64>`, `ProtoType`, `EnumType`, `STRUCT<INT64>`
func FormatTypeSimple ¶
FormatTypeSimple formats Cloud Spanner type as simple format. e.g. `INT64`, `ARRAY<INT64>`, `ProtoType`, `EnumType` `STRUCT`
func FormatTypeSimplest ¶
FormatTypeSimplest formats Cloud Spanner type as simplest format. e.g. `INT64`, `ARRAY, `PROTO`, `ENUM` `STRUCT`
func FormatTypeVerbose ¶
FormatTypeVerbose formats Cloud Spanner type as verbose format. e.g. `INT64`, `ARRAY<INT64>`, `examples.ProtoType`, `examples.EnumType`, `STRUCT<n INT64>`
Types ¶
type FormatOption ¶
type FormatOption struct {
Struct StructMode
Proto ProtoEnumMode
Enum ProtoEnumMode
Array ArrayMode
Unknown UnknownMode
}
FormatOption is a option for FormatType, and FormatStructFields.
type ProtoEnumMode ¶ added in v0.2.0
type ProtoEnumMode int
const ( // ProtoEnumModeBase formats `PROTO` and `ENUM` type as `PROTO` and `ENUM`. ProtoEnumModeBase ProtoEnumMode = iota // ProtoEnumModeLeaf formats `PROTO` and `ENUM` type without package name. e.g. `ProtoType`, `EnumType` ProtoEnumModeLeaf // ProtoEnumModeFull formats `PROTO` and `ENUM` type as full qualified name. e.g. `examples.ProtoType`, `examples.EnumType` ProtoEnumModeFull // ProtoEnumModeLeafWithKind formats `PROTO` and `ENUM` type without package name with kind. // e.g. `PROTO<ProtoType>`, `ENUM<EnumType>` ProtoEnumModeLeafWithKind // ProtoEnumModeFullWithKind formats `PROTO` and `ENUM` type as full qualified name with kind. // e.g. `PROTO<examples.ProtoType>`, `ENUM<examples.EnumType>`. // Note: It should be same format with `INFORMATION_SCHEMA.COLUMNS.SPANNER_TYPE`. ProtoEnumModeFullWithKind )
type StructMode ¶
type StructMode int
const ( // StructModeBase formats `STRUCT` type as `STRUCT`. StructModeBase StructMode = iota // StructModeRecursive formats `STRUCT` type with field types. e.g. `STRUCT<INT64, STRUCT<INT64>>` StructModeRecursive // StructModeRecursiveWithName formats `STRUCT` type with field types with field name. e.g. `STRUCT<n INT64, s STRUCT<n INT64>>` StructModeRecursiveWithName )
type UnknownMode ¶ added in v0.3.0
type UnknownMode int
const ( // UnknownModeUnknown formats unknown type code as `UNKNOWN` UnknownModeUnknown UnknownMode = iota // UnknownModeTypeCode formats unknown type code as e.g. `-1` UnknownModeTypeCode // UnknownModeVerbose formats unknown type code as `UNKNOWN(int32(code))` as e.g. `UNKNOWN(-1)` UnknownModeVerbose // UnknownModePanic panics when type code is unknown. UnknownModePanic )