data

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NdJSON = `application/x-ndjson`
	JSON   = `application/json`
)

Variables

This section is empty.

Functions

func ByteSrc

func ByteSrc(d []byte) ([]map[string]any, error)

StringSrc parses raw json formatted data.

func DecodeData

func DecodeData(r io.Reader, ct string, data *[]map[string]any) error

func DecodeDataO

func DecodeDataO(r io.Reader) ([]map[string]any, error)

DecodeDataO decodes data from a io.Reader.

func DecodeJSON

func DecodeJSON(r io.Reader, data *[]map[string]any) error

func DecodeNDJSON

func DecodeNDJSON(r io.Reader, data *[]map[string]any) error

DecodeNDJSON decodes data from a io.Reader.

func DirSrc

func DirSrc(dir string) ([]map[string]any, error)

DirSrc parses json files from a directory.

func FileSrc

func FileSrc(files ...string) ([]map[string]any, error)

FileSrc takes json data files.

func ReaderSrc

func ReaderSrc(r io.Reader) ([]map[string]any, error)

ReaderSrc takes an io.Reader of a json stream.

func StringSliceSrc

func StringSliceSrc(data []string) []map[string]any

StringSliceSrc takes a string slice and returns data for for indexing with the default field of 'title'.

func StringSrc

func StringSrc(d string) ([]map[string]any, error)

StringSrc parses index data from a json formatted string.

Types

type Data

type Data struct {
	Path  string
	Route string
	Files []*File
}

func New

func New(r, path string) *Data

func (*Data) AddFile

func (d *Data) AddFile(paths ...string)

func (*Data) Decode

func (d *Data) Decode() ([]map[string]any, error)

type File

type File struct {
	Path        string
	ContentType string
}

func NewFile

func NewFile(path string) (*File, error)

Jump to

Keyboard shortcuts

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