protoio

package
v0.0.0-...-0342304 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package protoio contains helper methods for proto I/O done by the testplan tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilepathAsJsonpb

func FilepathAsJsonpb(path string) string

FilepathAsJsonpb returns a copy of path, with the extension changed to ".jsonpb". If path is the empty string, an empty string is returned. Note that this function makes no attempt to check if the input path already has a jsonproto extension; i.e. if path is "a/b/test.jsonpb", the exact same path will be returned. Thus, it is up to the caller to check the returned path is different if this is required.

func ReadBinaryOrJSONPb

func ReadBinaryOrJSONPb(path string, m protov1.Message) error

ReadBinaryOrJSONPb reads path into m, attempting to parse as both a binary and json encoded proto.

This function is meant as a convenience so the CLI can take either json or binary protos as input. This function guesses at whether to attempt to parse as binary or json first based on path's suffix.

func ReadJsonl

func ReadJsonl[M proto.Message](inPath string, ctor func() M) ([]M, error)

ReadJsonl parses the newline-delimited jsonprotos in inPath. ctor must return a new empty proto to parse each line into.

func WriteJsonl

func WriteJsonl[M proto.Message](messages []M, outPath string) error

WriteJsonl writes a newline-delimited json file containing messages to outPath.

Types

This section is empty.

Jump to

Keyboard shortcuts

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