twirp

package module
v8.1.0-liftoff0+incomp... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Twirp Logo Build Status Go Report Card GoDoc


Twirp is a framework for service-to-service communication emphasizing simplicity and minimalism. It generates routing and serialization from API definition files and lets you focus on your application's logic instead of thinking about folderol like HTTP methods and paths and JSON.

Twirp is similar to gRPC, but without the custom HTTP server and transport implementations: it runs on the standard library's extremely-well-tested-and-high-performance net/http Server. It can run on HTTP 1.1, not just http/2, and supports JSON serialization for easy debugging.

Along the way, you get autogenerated clients and a simple, smart framework for passing error messages. Nice!

For more on the motivation behind Twirp (and a comparison to REST APIs and gRPC), the announcement blog post is a good read.

Documentation

Implementations in other languages

This repo contains the generator and runtime library for the Go implementation.

Here is a list of some third-party implementations in other languages.

Language Clients Servers Repository
Python3 github.com/verloop/twirpy
Java github.com/fajran/protoc-gen-twirp_java_jaxrs
Java https://github.com/devork/flit
JavaScript github.com/thechriswalker/protoc-gen-twirp_js
JavaScript github.com/Xe/twirp-codegens/cmd/protoc-gen-twirp_jsbrowser
Typescript https://github.com/hopin-team/twirp-ts
Typescript github.com/larrymyers/protoc-gen-twirp_typescript
Ruby github.com/twitchtv/twirp-ruby
Rust github.com/cretz/prost-twirp
Scala github.com/soundcloud/twinagle
Swagger github.com/go-bridget/twirp-swagger-gen
PHP github.com/twirphp/twirp
Dart github.com/apptreesoftware/protoc-gen-twirp_dart
Elixir github.com/keathley/twirp-elixir

Support and Community

We have a channel on the Gophers slack, #twirp, which is the best place to get quick answers to your questions. You can join the Gopher slack here.

Releases

Twirp follows semantic versioning through git tags, and uses Github Releases for release notes and upgrade guides: Twirp Releases

Contributing

Check out CONTRIBUTING.md for notes on making contributions.

License

This library is licensed under the Apache 2.0 License.

Documentation

Overview

Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/LICENSE-2.0

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package twirp provides core types used in generated Twirp servers and client.

Twirp services handle errors using the `twirp.Error` interface.

For example, a server method may return an InvalidArgumentError:

if req.Order != "DESC" && req.Order != "ASC" {
    return nil, twirp.InvalidArgumentError("Order", "must be DESC or ASC")
}

And the same twirp.Error is returned by the client, for example:

resp, err := twirpClient.RPCMethod(ctx, req)
if err != nil {
    if twerr, ok := err.(twirp.Error); ok {
        switch twerr.Code() {
        case twirp.InvalidArgument:
            log.Error("invalid argument "+twirp.Meta("argument"))
        default:
            log.Error(twerr.Error())
        }
    }
}

Clients may also return Internal errors if something failed on the system: the server, the network, or the client itself (i.e. failure parsing response).

Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/LICENSE-2.0

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://www.apache.org/licenses/LICENSE-2.0

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const TwirpPackageIsVersion7 = true

TwirpPackageIsVersion7 is a constant referenced from generated code to assert version compatibility at compile time.

View Source
const TwirpPackageMinVersion_8_1_0 = true

TwirpPackageMinVersion_8_1_0 is required from generated code to assert version compatibility at compile time.

Variables

This section is empty.

Functions

func AddHTTPResponseHeader

func AddHTTPResponseHeader(ctx context.Context, key, value string) error

AddHTTPResponseHeader behaves like SetHTTPResponseHeader, but it appends the key-value pair to the header (instead of replacing it).

AddHTTPResponseHeader returns an error if the key is "Content-Type".

func HTTPRequestHeaders

func HTTPRequestHeaders(ctx context.Context) (http.Header, bool)

func IsValidErrorCode

func IsValidErrorCode(code ErrorCode) bool

IsValidErrorCode returns true if is one of the valid predefined constants.

func MethodName

func MethodName(ctx context.Context) (string, bool)

MethodName extracts the name of the method being handled in the given context. If it is not known, it returns ("", false).

func PackageName

func PackageName(ctx context.Context) (string, bool)

PackageName extracts the fully-qualified protobuf package name of the service handling the given context. If it is not known, it returns ("", false). If the service comes from a proto file that does not declare a package name, it returns ("", true).

Note that the protobuf package name can be very different than the go package name; the two are unrelated.

func ServerHTTPStatusFromErrorCode

func ServerHTTPStatusFromErrorCode(code ErrorCode) int

ServerHTTPStatusFromErrorCode maps a Twirp error type into a similar HTTP response status. It is used by the Twirp server handler to set the HTTP response status code. Returns 0 if the ErrorCode is invalid.

func ServiceName

func ServiceName(ctx context.Context) (string, bool)

ServiceName extracts the name of the service handling the given context. If it is not known, it returns ("", false).

func SetHTTPResponseHeader

func SetHTTPResponseHeader(ctx context.Context, key, value string) error

SetHTTPResponseHeader sets an HTTP header key-value pair using a context provided by a twirp-generated server, or a child of that context. The server will include the header in its response for that request context.

This can be used to respond with custom HTTP headers like "Cache-Control". But note that HTTP headers are a Twirp implementation detail, only visible by middleware, not by the clients or their responses.

The header will be ignored (noop) if the context is invalid (i.e. using a new context.Background() instead of passing the context from the handler).

If called multiple times with the same key, it replaces any existing values associated with that key.

SetHTTPResponseHeader returns an error if the provided header key would overwrite a header that is needed by Twirp, like "Content-Type".

func StatusCode

func StatusCode(ctx context.Context) (string, bool)

StatusCode retrieves the status code of the response (as string like "200"). If it is known returns (status, true). If it is not known, it returns ("", false).

func WithHTTPRequestHeaders

func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error)

WithHTTPRequestHeaders stores an http.Header in a context.Context. When using a Twirp-generated client, you can pass the returned context into any of the request methods, and the stored header will be included in outbound HTTP requests.

This can be used to set custom HTTP headers like authorization tokens or client IDs. But note that HTTP headers are a Twirp implementation detail, only visible by middleware, not by the server implementation.

WithHTTPRequestHeaders returns an error if the provided http.Header would overwrite a header that is needed by Twirp, like "Content-Type".

func WriteError

func WriteError(resp http.ResponseWriter, err error) error

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware). If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type ClientHooks

type ClientHooks struct {
	// RequestPrepared is called as soon as a request has been created and before
	// it has been sent to the Twirp server.
	RequestPrepared func(context.Context, *http.Request) (context.Context, error)

	// ResponseReceived is called after a request has finished sending. Since this
	// is terminal, the context is not returned. ResponseReceived will not be
	// called in the case of an error being returned from the request.
	ResponseReceived func(context.Context)

	// Error hook is called whenever an error occurs during the sending of a
	// request. The Error is passed as an argument to the hook.
	Error func(context.Context, Error)
}

ClientHooks is a container for callbacks that can instrument a Twirp-generated client. These callbacks all accept a context and some return a context. They can use this to add to the context, appending values or deadlines to it.

The RequestPrepared hook is special because it can return errors. If it returns non-nil error, handling for that request will be stopped at that point. The Error hook will then be triggered.

The RequestPrepared hook will always be called first and will be called for each outgoing request from the Twirp client. The last hook to be called will either be Error or ResponseReceived, so be sure to handle both cases in your hooks.

func ChainClientHooks

func ChainClientHooks(hooks ...*ClientHooks) *ClientHooks

ChainClientHooks creates a new *ClientHooks which chains the callbacks in each of the constituent hooks passed in. Each hook function will be called in the order of the ClientHooks values passed in.

For the erroring hook, RequestPrepared, any returned errors prevent processing by later hooks.

type ClientOption

type ClientOption func(*ClientOptions)

ClientOption is a functional option for extending a Twirp client.

func WithClientHooks

func WithClientHooks(hooks *ClientHooks) ClientOption

WithClientHooks defines the hooks for a Twirp client.

func WithClientInterceptors

func WithClientInterceptors(interceptors ...Interceptor) ClientOption

WithClientInterceptors defines the interceptors for a Twirp client.

func WithClientLiteralURLs

func WithClientLiteralURLs(b bool) ClientOption

WithClientLiteralURLs configures the Twirp client to use the exact values as defined in the proto file for Service and Method names, fixing the issue https://github.com/twitchtv/twirp/issues/244, which is manifested when working with Twirp services implemented other languages (e.g. Python) and the proto file definitions are not properly following the [Protobuf Style Guide](https://developers.google.com/protocol-buffers/docs/style#services). By default (false), Go clients modify the routes by CamelCasing the values. For example, with Service: `haberdasher`, Method: `make_hat`, the URLs generated by Go clients are `Haberdasher/MakeHat`, but with this option enabled (true) the client will properly use `haberdasher/make_hat` instead.

func WithClientPathPrefix

func WithClientPathPrefix(prefix string) ClientOption

WithClientPathPrefix specifies a different prefix to use for routing. If not specified, the "/twirp" prefix is used by default. The service must be configured to serve on the same prefix. An empty value "" can be speficied to use no prefix. URL format: "<baseURL>[<prefix>]/<package>.<Service>/<Method>" More info on Twirp docs: https://twitchtv.github.io/twirp/docs/routing.html

type ClientOptions

type ClientOptions struct {
	Hooks        *ClientHooks
	Interceptors []Interceptor

	// Properties below are only used by code that was
	// generated by older versions of Twirp (before v8.1.0).
	// New options with standard types added in the future
	// don't need new properties, they should use ReadOpt.
	LiteralURLs bool
	// contains filtered or unexported fields
}

ClientOptions encapsulate the configurable parameters on a Twirp client. This type is meant to be used only by generated code.

func (*ClientOptions) PathPrefix

func (opts *ClientOptions) PathPrefix() string

PathPrefix() is used only by clients generated before v8.1.0

func (*ClientOptions) ReadOpt

func (opts *ClientOptions) ReadOpt(key string, out interface{}) bool

ReadOpt extracts an option to a pointer value, returns true if the option exists and was extracted. This method is meant to be used by generated code, keeping the type dependency outside of the runtime.

Usage example:

opts.setOpt("fooOpt", 123)
var foo int
ok := opts.ReadOpt("fooOpt", &int)

type Error

type Error interface {
	// Code is of the valid error codes.
	Code() ErrorCode

	// Msg returns a human-readable, unstructured messages describing the error.
	Msg() string

	// WithMeta returns a copy of the Error with the given key-value pair attached
	// as metadata. If the key is already set, it is overwritten.
	WithMeta(key string, val string) Error

	// Meta returns the stored value for the given key. If the key has no set
	// value, Meta returns an empty string. There is no way to distinguish between
	// an unset value and an explicit empty string.
	Meta(key string) string

	// MetaMap returns the complete key-value metadata map stored on the error.
	MetaMap() map[string]string

	// Error returns a string of the form "twirp error <Type>: <Msg>"
	Error() string
}

Error represents an error in a Twirp service call.

func InternalError

func InternalError(msg string) Error

InternalError constructor for the common Internal error. Should be used to specify that something bad or unexpected happened.

func InternalErrorWith

func InternalErrorWith(err error) Error

InternalErrorWith makes an internal error, wrapping the original error and using it for the error message, and with metadata "cause" with the original error type. This function is used by Twirp services to wrap non-Twirp errors as internal errors. The wrapped error can be extracted later with (github.com/pkg/errors).Unwrap or errors.Is from the standard errors package on Go 1.13+.

func InvalidArgumentError

func InvalidArgumentError(argument string, validationMsg string) Error

InvalidArgumentError constructor for the common InvalidArgument error. Can be used when an argument has invalid format, is a number out of range, is a bad option, etc).

func NewError

func NewError(code ErrorCode, msg string) Error

NewError is the generic constructor for a twirp.Error. The ErrorCode must be one of the valid predefined constants, otherwise it will be converted to an error {type: Internal, msg: "invalid error type {{code}}"}. If you need to add metadata, use .WithMeta(key, value) method after building the error.

func NotFoundError

func NotFoundError(msg string) Error

NotFoundError constructor for the common NotFound error.

func RequiredArgumentError

func RequiredArgumentError(argument string) Error

RequiredArgumentError is a more specific constructor for InvalidArgument error. Should be used when the argument is required (expected to have a non-zero value).

func WrapError

func WrapError(twerr Error, err error) Error

WrapError allows Twirp errors to wrap other errors. The wrapped error can be extracted later with (github.com/pkg/errors).Unwrap or errors.Is from the standard errors package on Go 1.13+.

type ErrorCode

type ErrorCode string

ErrorCode represents a Twirp error type.

const (
	// Canceled indicates the operation was cancelled (typically by the caller).
	Canceled ErrorCode = "canceled"

	// Unknown error. For example when handling errors raised by APIs that do not
	// return enough error information.
	Unknown ErrorCode = "unknown"

	// InvalidArgument indicates client specified an invalid argument. It
	// indicates arguments that are problematic regardless of the state of the
	// system (i.e. a malformed file name, required argument, number out of range,
	// etc.).
	InvalidArgument ErrorCode = "invalid_argument"

	// Malformed indicates an error occurred while decoding the client's request.
	// This may mean that the message was encoded improperly, or that there is a
	// disagreement in message format between the client and server.
	Malformed ErrorCode = "malformed"

	// DeadlineExceeded means operation expired before completion. For operations
	// that change the state of the system, this error may be returned even if the
	// operation has completed successfully (timeout).
	DeadlineExceeded ErrorCode = "deadline_exceeded"

	// NotFound means some requested entity was not found.
	NotFound ErrorCode = "not_found"

	// BadRoute means that the requested URL path wasn't routable to a Twirp
	// service and method. This is returned by the generated server, and usually
	// shouldn't be returned by applications. Instead, applications should use
	// NotFound or Unimplemented.
	BadRoute ErrorCode = "bad_route"

	// AlreadyExists means an attempt to create an entity failed because one
	// already exists.
	AlreadyExists ErrorCode = "already_exists"

	// PermissionDenied indicates the caller does not have permission to execute
	// the specified operation. It must not be used if the caller cannot be
	// identified (Unauthenticated).
	PermissionDenied ErrorCode = "permission_denied"

	// Unauthenticated indicates the request does not have valid authentication
	// credentials for the operation.
	Unauthenticated ErrorCode = "unauthenticated"

	// ResourceExhausted indicates some resource has been exhausted or rate-limited,
	// perhaps a per-user quota, or perhaps the entire file system is out of space.
	ResourceExhausted ErrorCode = "resource_exhausted"

	// FailedPrecondition indicates operation was rejected because the system is
	// not in a state required for the operation's execution. For example, doing
	// an rmdir operation on a directory that is non-empty, or on a non-directory
	// object, or when having conflicting read-modify-write on the same resource.
	FailedPrecondition ErrorCode = "failed_precondition"

	// Aborted indicates the operation was aborted, typically due to a concurrency
	// issue like sequencer check failures, transaction aborts, etc.
	Aborted ErrorCode = "aborted"

	// OutOfRange means operation was attempted past the valid range. For example,
	// seeking or reading past end of a paginated collection.
	//
	// Unlike InvalidArgument, this error indicates a problem that may be fixed if
	// the system state changes (i.e. adding more items to the collection).
	//
	// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
	// We recommend using OutOfRange (the more specific error) when it applies so
	// that callers who are iterating through a space can easily look for an
	// OutOfRange error to detect when they are done.
	OutOfRange ErrorCode = "out_of_range"

	// Unimplemented indicates operation is not implemented or not
	// supported/enabled in this service.
	Unimplemented ErrorCode = "unimplemented"

	// Internal errors. When some invariants expected by the underlying system
	// have been broken. In other words, something bad happened in the library or
	// backend service. Do not confuse with HTTP Internal Server Error; an
	// Internal error could also happen on the client code, i.e. when parsing a
	// server response.
	Internal ErrorCode = "internal"

	// Unavailable indicates the service is currently unavailable. This is a most
	// likely a transient condition and may be corrected by retrying with a
	// backoff.
	Unavailable ErrorCode = "unavailable"

	// DataLoss indicates unrecoverable data loss or corruption.
	DataLoss ErrorCode = "data_loss"

	// NoError is the zero-value, is considered an empty error and should not be
	// used.
	NoError ErrorCode = ""
)

Valid Twirp error types. Most error types are equivalent to gRPC status codes and follow the same semantics.

type Interceptor

type Interceptor func(Method) Method

Interceptor is a form of middleware for Twirp requests, that can be installed on both clients and servers. To intercept RPC calls in the client, use the option `twirp.WithClientInterceptors` on the client constructor. To intercept RPC calls in the server, use the option `twirp.WithServerInterceptors` on the server constructor.

Just like http middleware, interceptors can mutate requests and responses. This can enable some powerful integrations, but it should be used with much care because it may result in code that is very hard to debug.

Example of an interceptor that logs every request and response:

func LogInterceptor(l *log.Logger) twirp.Interceptor {
  return func(next twirp.Method) twirp.Method {
    return func(ctx context.Context, req interface{}) (interface{}, error) {
      l.Printf("Service: %s, Method: %s, Request: %v",
          twirp.ServiceName(ctx), twirp.MethodName(ctx), req)
      resp, err := next(ctx, req)
      l.Printf("Response: %v, Error: %v", resp)
      return resp, err
    }
  }
}

func ChainInterceptors

func ChainInterceptors(interceptors ...Interceptor) Interceptor

ChainInterceptors chains multiple Interceptors into a single Interceptor. The first interceptor wraps the second one, and so on. Returns nil if interceptors is empty. Nil interceptors are ignored.

type Method

type Method func(ctx context.Context, request interface{}) (interface{}, error)

Method is a generic representation of a Twirp-generated RPC method. It is used to define Interceptors.

type ServerHooks

type ServerHooks struct {
	// RequestReceived is called as soon as a request enters the Twirp
	// server at the earliest available moment.
	RequestReceived func(context.Context) (context.Context, error)

	// RequestRouted is called when a request has been routed to a
	// particular method of the Twirp server.
	RequestRouted func(context.Context) (context.Context, error)

	// ResponsePrepared is called when a request has been handled and a
	// response is ready to be sent to the client.
	ResponsePrepared func(context.Context) context.Context

	// ResponseSent is called when all bytes of a response (including an error
	// response) have been written. Because the ResponseSent hook is terminal, it
	// does not return a context.
	ResponseSent func(context.Context)

	// Error hook is called when an error occurs while handling a request. The
	// Error is passed as argument to the hook.
	Error func(context.Context, Error) context.Context
}

ServerHooks is a container for callbacks that can instrument a Twirp-generated server. These callbacks all accept a context and return a context. They can use this to add to the request context as it threads through the system, appending values or deadlines to it.

The RequestReceived and RequestRouted hooks are special: they can return errors. If they return a non-nil error, handling for that request will be stopped at that point. The Error hook will be triggered, and the error will be sent to the client. This can be used for stuff like auth checks before deserializing a request.

The RequestReceived hook is always called first, and it is called for every request that the Twirp server handles. The last hook to be called in a request's lifecycle is always ResponseSent, even in the case of an error.

Details on the timing of each hook are documented as comments on the fields of the ServerHooks type.

func ChainHooks

func ChainHooks(hooks ...*ServerHooks) *ServerHooks

ChainHooks creates a new *ServerHooks which chains the callbacks in each of the constituent hooks passed in. Each hook function will be called in the order of the ServerHooks values passed in.

For the erroring hooks, RequestReceived and RequestRouted, any returned errors prevent processing by later hooks.

type ServerOption

type ServerOption func(*ServerOptions)

ServerOption is a functional option for extending a Twirp service.

func WithServerHooks

func WithServerHooks(hooks *ServerHooks) ServerOption

WithServerHooks defines the hooks for a Twirp server.

func WithServerInterceptors

func WithServerInterceptors(interceptors ...Interceptor) ServerOption

WithServerInterceptors defines the interceptors for a Twirp server.

func WithServerJSONCamelCaseNames

func WithServerJSONCamelCaseNames(jsonCamelCase bool) ServerOption

WithServerJSONCamelCaseNames configures JSON serialization to use the default proto3 JSON encoding (lowerCamelCase) rather than the original proto field names. Twirp uses the original proto field names by default, because JSON encoding is often used for manual debugging of the API, but this option allows better compatibility with other proto-json parsers. See: https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson See: https://developers.google.com/protocol-buffers/docs/proto3#json

func WithServerJSONSkipDefaults

func WithServerJSONSkipDefaults(skipDefaults bool) ServerOption

WithServerJSONSkipDefaults configures JSON serialization to skip unpopulated or default values in JSON responses, which results in smaller response sizes. This was the default before v7 and can be enabled for full backwards compatibility if required. This is now disabled by default, because JSON serialization is commonly used for manual debugging, in which case it is useful to see the full shape of the response. See: https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson See: https://developers.google.com/protocol-buffers/docs/proto3#json

func WithServerPathPrefix

func WithServerPathPrefix(prefix string) ServerOption

WithServerPathPrefix specifies a different prefix for routing. If not specified, the "/twirp" prefix is used by default. An empty value "" can be speficied to use no prefix. The clients must be configured to send requests using the same prefix. URL format: "<baseURL>[<prefix>]/<package>.<Service>/<Method>" More info on Twirp docs: https://twitchtv.github.io/twirp/docs/routing.html

type ServerOptions

type ServerOptions struct {
	Hooks        *ServerHooks
	Interceptors []Interceptor

	// Properties below are only used by code that was
	// generated by older versions of Twirp (before v8.1.0).
	// New options with standard types added in the future
	// don't need new properties, they should use ReadOpt.
	JSONSkipDefaults bool
	// contains filtered or unexported fields
}

ServerOptions encapsulate the configurable parameters on a Twirp server. This type is meant to be used only by generated code.

func (*ServerOptions) PathPrefix

func (opts *ServerOptions) PathPrefix() string

PathPrefix() is used only by clients generated before v8.1.0

func (*ServerOptions) ReadOpt

func (opts *ServerOptions) ReadOpt(key string, out interface{}) bool

ReadOpt extracts an option to a pointer value, returns true if the option exists and was extracted. This method is meant to be used by generated code, keeping the type dependency outside of the runtime.

Usage example:

opts.setOpt("fooOpt", 123)
var foo int
ok := opts.ReadOpt("fooOpt", &int)

Directories

Path Synopsis
_tools
src/github.com/kisielk/errcheck/internal/errcheck
Package errcheck is the library used to implement the errcheck command-line tool.
Package errcheck is the library used to implement the errcheck command-line tool.
src/github.com/kisielk/gotool
Package gotool contains utility functions used to implement the standard "cmd/go" tool, provided as a convenience to developers who want to write tools with similar semantics.
Package gotool contains utility functions used to implement the standard "cmd/go" tool, provided as a convenience to developers who want to write tools with similar semantics.
src/github.com/kisielk/gotool/internal/load
Package load loads packages.
Package load loads packages.
src/golang.org/x/sys/execabs
Package execabs is a drop-in replacement for os/exec that requires PATH lookups to find absolute paths.
Package execabs is a drop-in replacement for os/exec that requires PATH lookups to find absolute paths.
src/golang.org/x/tools/go/ast/astutil
Package astutil contains common utilities for working with the Go AST.
Package astutil contains common utilities for working with the Go AST.
src/golang.org/x/tools/go/buildutil
Package buildutil provides utilities related to the go/build package in the standard library.
Package buildutil provides utilities related to the go/build package in the standard library.
src/golang.org/x/tools/go/loader
Package loader loads a complete Go program from source code, parsing and type-checking the initial packages plus their transitive closure of dependencies.
Package loader loads a complete Go program from source code, parsing and type-checking the initial packages plus their transitive closure of dependencies.
src/google.golang.org/protobuf/cmd/protoc-gen-go
The protoc-gen-go binary is a protoc plugin to generate Go code for both proto2 and proto3 versions of the protocol buffer language.
The protoc-gen-go binary is a protoc plugin to generate Go code for both proto2 and proto3 versions of the protocol buffer language.
src/google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo
Package internal_gengo is internal to the protobuf module.
Package internal_gengo is internal to the protobuf module.
src/google.golang.org/protobuf/compiler/protogen
Package protogen provides support for writing protoc plugins.
Package protogen provides support for writing protoc plugins.
src/google.golang.org/protobuf/encoding/prototext
Package prototext marshals and unmarshals protocol buffer messages as the textproto format.
Package prototext marshals and unmarshals protocol buffer messages as the textproto format.
src/google.golang.org/protobuf/encoding/protowire
Package protowire parses and formats the raw wire encoding.
Package protowire parses and formats the raw wire encoding.
src/google.golang.org/protobuf/internal/descfmt
Package descfmt provides functionality to format descriptors.
Package descfmt provides functionality to format descriptors.
src/google.golang.org/protobuf/internal/descopts
Package descopts contains the nil pointers to concrete descriptor options.
Package descopts contains the nil pointers to concrete descriptor options.
src/google.golang.org/protobuf/internal/detrand
Package detrand provides deterministically random functionality.
Package detrand provides deterministically random functionality.
src/google.golang.org/protobuf/internal/encoding/defval
Package defval marshals and unmarshals textual forms of default values.
Package defval marshals and unmarshals textual forms of default values.
src/google.golang.org/protobuf/internal/encoding/messageset
Package messageset encodes and decodes the obsolete MessageSet wire format.
Package messageset encodes and decodes the obsolete MessageSet wire format.
src/google.golang.org/protobuf/internal/encoding/tag
Package tag marshals and unmarshals the legacy struct tags as generated by historical versions of protoc-gen-go.
Package tag marshals and unmarshals the legacy struct tags as generated by historical versions of protoc-gen-go.
src/google.golang.org/protobuf/internal/encoding/text
Package text implements the text format for protocol buffers.
Package text implements the text format for protocol buffers.
src/google.golang.org/protobuf/internal/errors
Package errors implements functions to manipulate errors.
Package errors implements functions to manipulate errors.
src/google.golang.org/protobuf/internal/filedesc
Package filedesc provides functionality for constructing descriptors.
Package filedesc provides functionality for constructing descriptors.
src/google.golang.org/protobuf/internal/filetype
Package filetype provides functionality for wrapping descriptors with Go type information.
Package filetype provides functionality for wrapping descriptors with Go type information.
src/google.golang.org/protobuf/internal/flags
Package flags provides a set of flags controlled by build tags.
Package flags provides a set of flags controlled by build tags.
src/google.golang.org/protobuf/internal/genid
Package genid contains constants for declarations in descriptor.proto and the well-known types.
Package genid contains constants for declarations in descriptor.proto and the well-known types.
src/google.golang.org/protobuf/internal/order
Package order provides ordered access to messages and maps.
Package order provides ordered access to messages and maps.
src/google.golang.org/protobuf/internal/pragma
Package pragma provides types that can be embedded into a struct to statically enforce or prevent certain language properties.
Package pragma provides types that can be embedded into a struct to statically enforce or prevent certain language properties.
src/google.golang.org/protobuf/internal/set
Package set provides simple set data structures for uint64s.
Package set provides simple set data structures for uint64s.
src/google.golang.org/protobuf/internal/strs
Package strs provides string manipulation functionality specific to protobuf.
Package strs provides string manipulation functionality specific to protobuf.
src/google.golang.org/protobuf/internal/version
Package version records versioning information about this module.
Package version records versioning information about this module.
src/google.golang.org/protobuf/proto
Package proto provides functions operating on protocol buffer messages.
Package proto provides functions operating on protocol buffer messages.
src/google.golang.org/protobuf/reflect/protodesc
Package protodesc provides functionality for converting FileDescriptorProto messages to/from protoreflect.FileDescriptor values.
Package protodesc provides functionality for converting FileDescriptorProto messages to/from protoreflect.FileDescriptor values.
src/google.golang.org/protobuf/reflect/protoreflect
Package protoreflect provides interfaces to dynamically manipulate messages.
Package protoreflect provides interfaces to dynamically manipulate messages.
src/google.golang.org/protobuf/reflect/protoregistry
Package protoregistry provides data structures to register and lookup protobuf descriptor types.
Package protoregistry provides data structures to register and lookup protobuf descriptor types.
src/google.golang.org/protobuf/runtime/protoiface
Package protoiface contains types referenced or implemented by messages.
Package protoiface contains types referenced or implemented by messages.
src/google.golang.org/protobuf/runtime/protoimpl
Package protoimpl contains the default implementation for messages generated by protoc-gen-go.
Package protoimpl contains the default implementation for messages generated by protoc-gen-go.
Package ctxsetters is an implementation detail for twirp generated code, used by the generated servers to set values in contexts for later access with the twirp package's accessors.
Package ctxsetters is an implementation detail for twirp generated code, used by the generated servers to set values in contexts for later access with the twirp package's accessors.
hooks
internal
contextkeys
Package contextkeys stores the keys to the context accessor functions, letting generated code safely set values in contexts without exposing the setters to the outside world.
Package contextkeys stores the keys to the context accessor functions, letting generated code safely set values in contexts without exposing the setters to the outside world.
descriptors
package descriptors provides tools for manipulating and inspecting protobuf descriptors.
package descriptors provides tools for manipulating and inspecting protobuf descriptors.
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL