filebasics

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize added in v0.1.8

func Deserialize(data []byte) (map[string]interface{}, error)

Deserialize will deserialize data as a JSON or YAML object. Will return an error if deserializing fails or if it isn't an object.

func DeserializeFile added in v0.1.8

func DeserializeFile(filename string) (map[string]interface{}, error)

DeserializeFile will read a JSON or YAML file and return the top-level object. Will return an error if it fails reading or the content isn't an object. Reads from stdin if filename == "-".

func MustDeserialize

func MustDeserialize(data []byte) map[string]interface{}

MustDeserialize will deserialize data as a JSON or YAML object. Will panic if deserializing fails or if it isn't an object. Will never return nil.

func MustDeserializeFile

func MustDeserializeFile(filename string) map[string]interface{}

MustDeserializeFile will read a JSON or YAML file and return the top-level object. Will panic if it fails reading or the content isn't an object. Reads from stdin if filename == "-". This will never return nil.

func MustReadFile

func MustReadFile(filename string) []byte

MustReadFile reads file contents. Will panic if reading fails. Reads from stdin if filename == "-"

func MustSerialize

func MustSerialize(content map[string]interface{}, format OutputFormat) []byte

MustSerialize will serialize the result as a JSON/YAML. Will panic if serializing fails.

func MustWriteFile

func MustWriteFile(filename string, content []byte)

MustWriteFile writes the output to a file. Will panic if writing fails. Writes to stdout if filename == "-"

func MustWriteSerializedFile

func MustWriteSerializedFile(filename string, content map[string]interface{}, format OutputFormat)

MustWriteSerializedFile will serialize the data and write it to a file. Will panic if it fails. Writes to stdout if filename == "-"

func ReadFile added in v0.1.8

func ReadFile(filename string) ([]byte, error)

ReadFile reads file contents. Reads from stdin if filename == "-"

func Serialize added in v0.1.14

func Serialize(content map[string]interface{}, format OutputFormat) ([]byte, error)

Serialize will serialize the result as a JSON/YAML. Format parameter is case-insensitive.

func WriteFile added in v0.1.14

func WriteFile(filename string, content []byte) error

WriteFile writes the output to a file. Writes to stdout if filename == "-"

func WriteSerializedFile added in v0.1.14

func WriteSerializedFile(filename string, content map[string]interface{}, format OutputFormat) error

WriteSerializedFile will serialize the data and write it to a file. Writes to stdout if filename == "-"

Types

type OutputFormat added in v0.1.18

type OutputFormat string
const (
	OutputFormatYaml OutputFormat = "yaml"
	OutputFormatJSON OutputFormat = "json"
)

Jump to

Keyboard shortcuts

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