format

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package format package contains interfaces to implement to allow read/write of various file types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Readable

type Readable interface {
	// Initialize should initialize a encoding/<format> reader from the underlying file.
	Initialize(file *os.File) error
	// ReadHeader should return a list of column names.
	ReadHeader() ([]string, error)
	// ReadRecord should read a single record and return it as a map[string]string where column name is key and column value is value.
	ReadRecord(headers []string) (map[string]string, error)
}

Readable is an interface for file types that can be read from.

type Writable

type Writable interface {
	// WriteHeader should be called at the beginning of the file write process.
	WriteHeader(file *os.File, columns []string) error
	// WriteRecord should be called for every record in the source data.
	WriteRecord(file *os.File, row map[string]string, index int) error
	// WriteFooter should be called after every record has been written with WriteRecord.
	WriteFooter(file *os.File) error
}

Writable is for file types that can be written to.

Directories

Path Synopsis
Package csv contains implementation of format interfaces for CSV document type.
Package csv contains implementation of format interfaces for CSV document type.
Package json contains implementation of format interfaces for JSON document type.
Package json contains implementation of format interfaces for JSON document type.

Jump to

Keyboard shortcuts

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