buf: github.com/bufbuild/buf/internal/pkg/encoding Index | Files

package encoding

import "github.com/bufbuild/buf/internal/pkg/encoding"

Package encoding provides encoding utilities.

Index

Package Files

encoding.go

func GetJSONStringOrStringValue Uses

func GetJSONStringOrStringValue(rawMessage json.RawMessage) string

GetJSONStringOrStringValue returns the JSON string for the RawMessage if the RawMessage is a string, and the raw value as a string otherwise.

If the RawMessage is empty, this returns "".

func MarshalYAML Uses

func MarshalYAML(v interface{}) (_ []byte, retErr error)

MarshalYAML marshals the given value into YAML.

func NewYAMLDecoderNonStrict Uses

func NewYAMLDecoderNonStrict(reader io.Reader) *yaml.Decoder

NewYAMLDecoderNonStrict creates a new YAML decoder from the reader.

func NewYAMLDecoderStrict Uses

func NewYAMLDecoderStrict(reader io.Reader) *yaml.Decoder

NewYAMLDecoderStrict creates a new YAML decoder from the reader.

func NewYAMLEncoder Uses

func NewYAMLEncoder(writer io.Writer) *yaml.Encoder

NewYAMLEncoder creates a new YAML encoder reader from the Writer. The encoder must be closed after use.

func UnmarshalJSONNonStrict Uses

func UnmarshalJSONNonStrict(data []byte, v interface{}) error

UnmarshalJSONNonStrict unmarshals the data as JSON, returning a user error on failure.

If the data length is 0, this is a no-op.

func UnmarshalJSONOrYAMLNonStrict Uses

func UnmarshalJSONOrYAMLNonStrict(data []byte, v interface{}) error

UnmarshalJSONOrYAMLNonStrict unmarshals the data as JSON or YAML in order, returning a user error with both errors on failure.

If the data length is 0, this is a no-op.

func UnmarshalJSONOrYAMLStrict Uses

func UnmarshalJSONOrYAMLStrict(data []byte, v interface{}) error

UnmarshalJSONOrYAMLStrict unmarshals the data as JSON or YAML in order, returning a user error with both errors on failure.

If the data length is 0, this is a no-op.

func UnmarshalJSONStrict Uses

func UnmarshalJSONStrict(data []byte, v interface{}) error

UnmarshalJSONStrict unmarshals the data as JSON, returning a user error on failure.

If the data length is 0, this is a no-op.

func UnmarshalYAMLNonStrict Uses

func UnmarshalYAMLNonStrict(data []byte, v interface{}) error

UnmarshalYAMLNonStrict unmarshals the data as YAML, returning a user error on failure.

If the data length is 0, this is a no-op.

func UnmarshalYAMLStrict Uses

func UnmarshalYAMLStrict(data []byte, v interface{}) error

UnmarshalYAMLStrict unmarshals the data as YAML, returning a user error on failure.

If the data length is 0, this is a no-op.

Package encoding imports 7 packages (graph) and is imported by 2 packages. Updated 2020-10-20. Refresh now. Tools for package owners.