package text
Import Path
google.golang.org/protobuf/internal/encoding/text (on go.dev)
Dependency Relation
imports 14 packages, and imported by 2 packages
Involved Source Files
decode.go
decode_number.go
decode_string.go
decode_token.go
Package text implements the text format for protocol buffers.
This package has no semantic understanding for protocol buffers and is only
a parser and composer for the format.
There is no formal specification for the protobuf text format, as such the
C++ implementation (see google::protobuf::TextFormat) is the reference
implementation of the text format.
This package is neither a superset nor a subset of the C++ implementation.
This implementation permits a more liberal grammar in some cases to be
backwards compatible with the historical Go implementation.
Future parsings unique to Go should not be added.
Some grammars allowed by the C++ implementation are deliberately
not implemented here because they are considered a bug by the protobuf team
and should not be replicated.
The Go implementation should implement a sufficient amount of the C++
grammar such that the default text serialization by C++ can be parsed by Go.
However, just because the C++ parser accepts some input does not mean that
the Go implementation should as well.
The text format is almost a superset of JSON except:
- message keys are not quoted strings, but identifiers
- the top-level value must be a message without the delimiters
encode.go
Package-Level Type Names (total 5)
Decoder is a token-based textproto decoder.
Peek looks ahead and returns the next token and error without advancing a read.
Position returns line and column number of given index of the original input.
It will panic if index is out of range.
Read returns the next token.
It will return an error if there is no valid token.
func NewDecoder(b []byte) *Decoder
Encoder provides methods to write out textproto constructs and values. The user is
responsible for producing valid sequences of constructs and values.
Bytes returns the content of the written bytes.
EndMessage writes out the '}' or '>' symbol.
Reset resets the Encoder to the given encoderState from a Snapshot.
Snapshot returns the current snapshot for use in Reset.
StartMessage writes out the '{' or '<' symbol.
WriteBool writes out the given boolean value.
WriteFloat writes out the given float value for given bitSize.
WriteInt writes out the given signed integer value.
WriteLiteral writes out the given string as a literal value without quotes.
This is used for writing enum literal strings.
WriteName writes out the field name and the separator ':'.
WriteString writes out the given string value.
WriteUint writes out the given unsigned integer value.
*Encoder : github.com/apache/arrow-go/v18/internal/hashing.ByteSlice
func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error)
Kind represents a token kind expressible in the textproto format.
( Kind) String() string
Kind : expvar.Var
Kind : fmt.Stringer
func Token.Kind() Kind
const EOF
const Invalid
const ListClose
const ListOpen
const MessageClose
const MessageOpen
const Name
const Scalar
NameKind represents different types of field names.
( NameKind) String() string
NameKind : expvar.Var
NameKind : fmt.Stringer
func Token.NameKind() NameKind
const FieldNumber
const IdentName
const TypeName
Token provides a parsed token kind and value. Values are provided by the
different accessor methods.
Bool returns the bool value for a Scalar type.
Enum returns the literal value for a Scalar type for use as enum literals.
FieldNumber returns the value for FieldNumber type. It returns a
non-negative int32 value. Caller will still need to validate for the correct
field number range.
Float32 returns the float32 value for a Scalar type.
Float64 returns the float64 value for a Scalar type.
HasSeparator returns true if the field name is followed by the separator char
':', else false. It panics if type is not Name.
IdentName returns the value for IdentName type.
Int32 returns the int32 value for a Scalar type.
Int64 returns the int64 value for a Scalar type.
Kind returns the token kind.
NameKind returns IdentName, TypeName or FieldNumber.
It panics if type is not Name.
Pos returns the token position from the input.
RawString returns the read value in string.
String returns the string value for a Scalar type.
TypeName returns the value for TypeName type.
Uint32 returns the uint32 value for a Scalar type.
Uint64 returns the uint64 value for a Scalar type.
Token : github.com/apache/arrow-go/v18/arrow/compute.FunctionOptions
func (*Decoder).Peek() (Token, error)
func (*Decoder).Read() (Token, error)
func TokenEquals(x, y Token) bool
Package-Level Functions (total 5)
AppendString appends the escaped form of the input string to b.
NewDecoder returns a Decoder to read the given []byte.
NewEncoder returns an Encoder.
If indent is a non-empty string, it causes every entry in a List or Message
to be preceded by the indent and trailed by a newline.
If delims is not the zero value, it controls the delimiter characters used
for messages (e.g., "{}" vs "<>").
If outputASCII is true, strings will be serialized in such a way that
multi-byte UTF-8 sequences are escaped. This property ensures that the
overall output is ASCII (as opposed to UTF-8).
TokenEquals returns true if given Tokens are equal, else false.
UnmarshalString returns an unescaped string given a textproto string value.
String value needs to contain single or double quotes. This is only used by
internal/encoding/defval package for unmarshaling bytes.
Package-Level Variables (only one)
ErrUnexpectedEOF means that EOF was encountered in the middle of the input.
Package-Level Constants (total 11)
Kind values.
NameKind values.
NameKind values.
Kind values.
Kind values.
Kind values.
Kind values.
Kind values.
Kind values.
Kind values.
NameKind values.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |