filebasics

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

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{}, asYaml bool) *[]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{}, asYaml bool)

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 == "-"

Types

This section is empty.

Jump to

Keyboard shortcuts

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