proto

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeMarshalResponseBodyFailed *string
)

Functions

func PrecomputeMarshalByReflection

func PrecomputeMarshalByReflection(
	v reflect.Value,
	marshalOptions *protojson.MarshalOptions,
) (map[string]interface{}, error)

PrecomputeMarshalByReflection marshals a struct to a map[string]interface{} using reflection, handling nested proto.Message fields appropriately

Parameters:

  • v: The reflect.Value of the struct to marshal
  • marshalOptions: The protojson.MarshalOptions to use (optional)

Returns:

  • map[string]interface{}: The marshaled struct as a map
  • error: The error if any

Types

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder is the implementation of the Encoder interface

func NewEncoder

func NewEncoder(
	mode *goflagsmode.Flag,
	marshalOptions protojson.MarshalOptions,
) *Encoder

NewEncoder creates a new Encoder instance

Parameters:

  • mode: the flag mode
  • marshalOptions: options for marshaling protobuf messages to JSON

Returns:

- *Encoder: the new Encoder instance

func (Encoder) Encode

func (e Encoder) Encode(
	w http.ResponseWriter,
	response gonethttpresponse.Response,
) error

Encode protobuf to JSON

Parameters:

  • w: The HTTP response writer
  • response: The response to encode, must have a data field that is a proto.Message

Returns:

  • error: The error if any

Jump to

Keyboard shortcuts

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