pkg.go.dev
Open in
urlscan Pro
2600:1901:0:f535::
Public Scan
Submitted URL: http://google.golang.org/protobuf/internal/encoding/text
Effective URL: https://pkg.go.dev/google.golang.org/protobuf/internal/encoding/text
Submission: On October 29 via api from US — Scanned from DE
Effective URL: https://pkg.go.dev/google.golang.org/protobuf/internal/encoding/text
Submission: On October 29 via api from US — Scanned from DE
Form analysis
3 forms found in the DOM/search
<form class="go-InputGroup go-ShortcutKey go-SearchForm-form" action="/search" data-shortcut="/" data-shortcut-alt="search" data-gtmc="search form" aria-label="Search for a package" role="search">
<input name="q" class="go-Input js-searchFocus" aria-label="Search for a package" type="search" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" placeholder="Search packages or symbols" value="">
<input name="m" value="" hidden="">
<button class="go-Button go-Button--inverted" aria-label="Submit search">
<img class="go-Icon" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt="">
</button>
</form>
DIALOG
<form method="dialog" data-gmtc="jump to form" aria-label="Jump to Identifier">
<div class="Dialog-title go-Modal-header">
<h2>Jump to</h2>
<button class="go-Button go-Button--inline" type="button" data-modal-close="" data-gtmc="modal button" aria-label="Close">
<img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="">
</button>
</div>
<div class="JumpDialog-filter">
<input class="JumpDialog-input go-Input" autocomplete="off" type="text">
</div>
<div class="JumpDialog-body go-Modal-body">
<div class="JumpDialog-list"></div>
</div>
<div class="go-Modal-actions">
<button class="go-Button" data-test-id="close-dialog">Close</button>
</div>
</form>
DIALOG
<form method="dialog">
<div class="go-Modal-header">
<h2>Keyboard shortcuts</h2>
<button class="go-Button go-Button--inline" type="button" data-modal-close="" data-gtmc="modal button" aria-label="Close">
<img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="">
</button>
</div>
<div class="go-Modal-body">
<table>
<tbody>
<tr>
<td class="ShortcutsDialog-key">
<strong>?</strong>
</td>
<td> : This menu</td>
</tr>
<tr>
<td class="ShortcutsDialog-key">
<strong>/</strong>
</td>
<td> : Search site</td>
</tr>
<tr>
<td class="ShortcutsDialog-key">
<strong>f</strong> or <strong>F</strong>
</td>
<td> : Jump to</td>
</tr>
<tr>
<td class="ShortcutsDialog-key"><strong>y</strong> or <strong>Y</strong></td>
<td> : Canonical URL</td>
</tr>
</tbody>
</table>
</div>
<div class="go-Modal-actions">
<button class="go-Button" data-test-id="close-dialog">Close</button>
</div>
</form>
Text Content
Skip to Main Content * Why Go * Case Studies Common problems companies solve with Go * Use Cases Stories about how and why companies use Go * Security Policy How Go can help keep you secure by default * Learn * Docs * Effective Go Tips for writing clear, performant, and idiomatic Go code * Go User Manual A complete introduction to building software with Go * Standard library Reference documentation for Go's standard library * Release Notes Learn what's new in each Go release * Packages * Community * Recorded Talks Videos from prior events * Meetups Meet other local Go developers * Conferences Learn and network with Go developers from around the world * Go blog The Go project's official blog. * Go project Get help and stay informed from Go * Get connected * Why Go Why Go * Case Studies * Use Cases * Security Policy * Learn * Docs Docs * Effective Go * Go User Manual * Standard library * Release Notes * Packages * Community Community * Recorded Talks * Meetups * Conferences * Go blog * Go project * Get connected 1. Discover Packages 2. google.golang.org/protobuf 3. internal 4. encoding 5. text TEXT package Version: v1.35.1 Opens a new window with list of versions in this module. Latest Latest This package is not in the latest version of its module. Go to latest Published: Oct 7, 2024 License: BSD-3-Clause Opens a new window with license information. Imports: 14 Opens a new window with list of imports. Imported by: 0 Opens a new window with list of known importers. Main Versions Licenses Imports Imported By DETAILS * Valid go.mod file The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go. * Redistributable license Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed. * Tagged version Modules with tagged versions give importers more predictable builds. * Stable version When a project reaches major version v1 it is considered stable. * Learn more about best practices REPOSITORY github.com/protocolbuffers/protobuf-go LINKS * Open Source Insights Jump to ... * Documentation * Overview * Index * Constants * Variables * Functions * AppendString(b, s) * TokenEquals(x, y) * UnmarshalString(s) * Types * type Decoder * NewDecoder(b) * (d) Peek() * (d) Position(idx) * (d) Read() * type Encoder * NewEncoder(buf, indent, delims, outputASCII) * (e) Bytes() * (e) EndMessage() * (e) Reset(es) * (e) Snapshot() * (e) StartMessage() * (e) WriteBool(b) * (e) WriteFloat(n, bitSize) * (e) WriteInt(n) * (e) WriteLiteral(s) * (e) WriteName(s) * (e) WriteString(s) * (e) WriteUint(n) * type Kind * (t) String() * type NameKind * (t) String() * type Token * (t) Bool() * (t) Enum() * (t) FieldNumber() * (t) Float32() * (t) Float64() * (t) HasSeparator() * (t) IdentName() * (t) Int32() * (t) Int64() * (t) Kind() * (t) NameKind() * (t) Pos() * (t) RawString() * (t) String() * (t) TypeName() * (t) Uint32() * (t) Uint64() * Source Files DocumentationSource FilesOverviewIndexConstantsVariablesFunctionsTypesAppendString(b, s)TokenEquals(x, y)UnmarshalString(s)type Decodertype Encodertype Kindtype NameKindtype TokenNewDecoder(b)(d) Peek()(d) Position(idx)(d) Read()NewEncoder(buf, indent, delims, outputASCII)(e) Bytes()(e) EndMessage()(e) Reset(es)(e) Snapshot()(e) StartMessage()(e) WriteBool(b)(e) WriteFloat(n, bitSize)(e) WriteInt(n)(e) WriteLiteral(s)(e) WriteName(s)(e) WriteString(s)(e) WriteUint(n)(t) String()(t) String()(t) Bool()(t) Enum()(t) FieldNumber()(t) Float32()(t) Float64()(t) HasSeparator()(t) IdentName()(t) Int32()(t) Int64()(t) Kind()(t) NameKind()(t) Pos()(t) RawString()(t) String()(t) TypeName()(t) Uint32()(t) Uint64() DOCUMENTATION ¶ OVERVIEW ¶ 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 INDEX ¶ * Variables * func AppendString(b []byte, s string) []byte * func TokenEquals(x, y Token) bool * func UnmarshalString(s string) (string, error) * type Decoder * * func NewDecoder(b []byte) *Decoder * * func (d *Decoder) Peek() (Token, error) * func (d *Decoder) Position(idx int) (line int, column int) * func (d *Decoder) Read() (Token, error) * type Encoder * * func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error) * * func (e *Encoder) Bytes() []byte * func (e *Encoder) EndMessage() * func (e *Encoder) Reset(es encoderState) * func (e *Encoder) Snapshot() encoderState * func (e *Encoder) StartMessage() * func (e *Encoder) WriteBool(b bool) * func (e *Encoder) WriteFloat(n float64, bitSize int) * func (e *Encoder) WriteInt(n int64) * func (e *Encoder) WriteLiteral(s string) * func (e *Encoder) WriteName(s string) * func (e *Encoder) WriteString(s string) * func (e *Encoder) WriteUint(n uint64) * type Kind * * func (t Kind) String() string * type NameKind * * func (t NameKind) String() string * type Token * * func (t Token) Bool() (bool, bool) * func (t Token) Enum() (string, bool) * func (t Token) FieldNumber() int32 * func (t Token) Float32() (float32, bool) * func (t Token) Float64() (float64, bool) * func (t Token) HasSeparator() bool * func (t Token) IdentName() string * func (t Token) Int32() (int32, bool) * func (t Token) Int64() (int64, bool) * func (t Token) Kind() Kind * func (t Token) NameKind() NameKind * func (t Token) Pos() int * func (t Token) RawString() string * func (t Token) String() (string, bool) * func (t Token) TypeName() string * func (t Token) Uint32() (uint32, bool) * func (t Token) Uint64() (uint64, bool) CONSTANTS ¶ This section is empty. VARIABLES ¶ View Source var ErrUnexpectedEOF = errors.New("%v", io.ErrUnexpectedEOF) ErrUnexpectedEOF means that EOF was encountered in the middle of the input. FUNCTIONS ¶ FUNC APPENDSTRING ¶ ADDED IN V1.27.0 func AppendString(b []byte, s string) []byte AppendString appends the escaped form of the input string to b. FUNC TOKENEQUALS ¶ func TokenEquals(x, y Token) bool TokenEquals returns true if given Tokens are equal, else false. FUNC UNMARSHALSTRING ¶ func UnmarshalString(s string) (string, error) 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. TYPES ¶ TYPE DECODER ¶ type Decoder struct { // contains filtered or unexported fields } Decoder is a token-based textproto decoder. FUNC NEWDECODER ¶ func NewDecoder(b []byte) *Decoder NewDecoder returns a Decoder to read the given []byte. FUNC (*DECODER) PEEK ¶ func (d *Decoder) Peek() (Token, error) Peek looks ahead and returns the next token and error without advancing a read. FUNC (*DECODER) POSITION ¶ func (d *Decoder) Position(idx int) (line int, column int) Position returns line and column number of given index of the original input. It will panic if index is out of range. FUNC (*DECODER) READ ¶ func (d *Decoder) Read() (Token, error) Read returns the next token. It will return an error if there is no valid token. TYPE ENCODER ¶ type Encoder struct { // contains filtered or unexported fields } Encoder provides methods to write out textproto constructs and values. The user is responsible for producing valid sequences of constructs and values. FUNC NEWENCODER ¶ func NewEncoder(buf []byte, indent string, delims [2]byte, outputASCII bool) (*Encoder, error) 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). FUNC (*ENCODER) BYTES ¶ func (e *Encoder) Bytes() []byte Bytes returns the content of the written bytes. FUNC (*ENCODER) ENDMESSAGE ¶ func (e *Encoder) EndMessage() EndMessage writes out the '}' or '>' symbol. FUNC (*ENCODER) RESET ¶ func (e *Encoder) Reset(es encoderState) Reset resets the Encoder to the given encoderState from a Snapshot. FUNC (*ENCODER) SNAPSHOT ¶ func (e *Encoder) Snapshot() encoderState Snapshot returns the current snapshot for use in Reset. FUNC (*ENCODER) STARTMESSAGE ¶ func (e *Encoder) StartMessage() StartMessage writes out the '{' or '<' symbol. FUNC (*ENCODER) WRITEBOOL ¶ func (e *Encoder) WriteBool(b bool) WriteBool writes out the given boolean value. FUNC (*ENCODER) WRITEFLOAT ¶ func (e *Encoder) WriteFloat(n float64, bitSize int) WriteFloat writes out the given float value for given bitSize. FUNC (*ENCODER) WRITEINT ¶ func (e *Encoder) WriteInt(n int64) WriteInt writes out the given signed integer value. FUNC (*ENCODER) WRITELITERAL ¶ func (e *Encoder) WriteLiteral(s string) WriteLiteral writes out the given string as a literal value without quotes. This is used for writing enum literal strings. FUNC (*ENCODER) WRITENAME ¶ func (e *Encoder) WriteName(s string) WriteName writes out the field name and the separator ':'. FUNC (*ENCODER) WRITESTRING ¶ func (e *Encoder) WriteString(s string) WriteString writes out the given string value. FUNC (*ENCODER) WRITEUINT ¶ func (e *Encoder) WriteUint(n uint64) WriteUint writes out the given unsigned integer value. TYPE KIND ¶ type Kind uint8 Kind represents a token kind expressible in the textproto format. const ( Invalid Kind = iota EOF Name // Name indicates the field name. Scalar // Scalar are scalar values, e.g. "string", 47, ENUM_LITERAL, true. MessageOpen MessageClose ListOpen ListClose ) Kind values. FUNC (KIND) STRING ¶ func (t Kind) String() string TYPE NAMEKIND ¶ type NameKind uint8 NameKind represents different types of field names. const ( IdentName NameKind = iota + 1 TypeName FieldNumber ) NameKind values. FUNC (NAMEKIND) STRING ¶ func (t NameKind) String() string TYPE TOKEN ¶ type Token struct { // contains filtered or unexported fields } Token provides a parsed token kind and value. Values are provided by the different accessor methods. FUNC (TOKEN) BOOL ¶ func (t Token) Bool() (bool, bool) Bool returns the bool value for a Scalar type. FUNC (TOKEN) ENUM ¶ func (t Token) Enum() (string, bool) Enum returns the literal value for a Scalar type for use as enum literals. FUNC (TOKEN) FIELDNUMBER ¶ func (t Token) FieldNumber() int32 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. FUNC (TOKEN) FLOAT32 ¶ func (t Token) Float32() (float32, bool) Float32 returns the float32 value for a Scalar type. FUNC (TOKEN) FLOAT64 ¶ func (t Token) Float64() (float64, bool) Float64 returns the float64 value for a Scalar type. FUNC (TOKEN) HASSEPARATOR ¶ func (t Token) HasSeparator() bool HasSeparator returns true if the field name is followed by the separator char ':', else false. It panics if type is not Name. FUNC (TOKEN) IDENTNAME ¶ func (t Token) IdentName() string IdentName returns the value for IdentName type. FUNC (TOKEN) INT32 ¶ func (t Token) Int32() (int32, bool) Int32 returns the int32 value for a Scalar type. FUNC (TOKEN) INT64 ¶ func (t Token) Int64() (int64, bool) Int64 returns the int64 value for a Scalar type. FUNC (TOKEN) KIND ¶ func (t Token) Kind() Kind Kind returns the token kind. FUNC (TOKEN) NAMEKIND ¶ func (t Token) NameKind() NameKind NameKind returns IdentName, TypeName or FieldNumber. It panics if type is not Name. FUNC (TOKEN) POS ¶ func (t Token) Pos() int Pos returns the token position from the input. FUNC (TOKEN) RAWSTRING ¶ func (t Token) RawString() string RawString returns the read value in string. FUNC (TOKEN) STRING ¶ func (t Token) String() (string, bool) String returns the string value for a Scalar type. FUNC (TOKEN) TYPENAME ¶ func (t Token) TypeName() string TypeName returns the value for TypeName type. FUNC (TOKEN) UINT32 ¶ func (t Token) Uint32() (uint32, bool) Uint32 returns the uint32 value for a Scalar type. FUNC (TOKEN) UINT64 ¶ func (t Token) Uint64() (uint64, bool) Uint64 returns the uint64 value for a Scalar type. SOURCE FILES ¶ View all Source files * decode.go * decode_number.go * decode_string.go * decode_token.go * doc.go * encode.go Click to show internal directories. Click to hide internal directories. Why Go Use Cases Case Studies Get Started Playground Tour Stack Overflow Help Packages Standard Library Sub-repositories About Go Packages About Download Blog Issue Tracker Release Notes Brand Guidelines Code of Conduct Connect Twitter GitHub Slack r/golang Meetup Golang Weekly * Copyright * Terms of Service * Privacy Policy * Report an Issue * Theme Toggle * Shortcuts Modal JUMP TO Close KEYBOARD SHORTCUTS ? : This menu / : Search site f or F : Jump to y or Y : Canonical URL Close go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. Learn more. Okay