config

package
v0.0.0-...-b2a609f Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InferFormat

func InferFormat(file string) string

InferFormat tries to infer the format of the file from its extension. An empty string is returned in case format cannot be inferred

func ValidateConfig

func ValidateConfig(count int, outFile, format, mode, fields string) error

ValidateConfig validates configuration. nil is returned in case configuration is valid Call InferFormat prior to this function in case format is empty. format argument must not be empty

Types

type Config

type Config struct {
	// number of random rows to generate
	Count int

	// output file
	OutFile string

	// output format
	Format Format

	Mode Mode

	ProjectedFields map[string]bool
}

func NewConfig

func NewConfig(count int, outFile, format, mode, fields string) *Config

NewConfig creates a new Config object. You shall call ValidateConfig before calling this function

func (*Config) Fields

func (conf *Config) Fields() []string

Fields returns all the fields to be projected if some field has custom format, only its name is returned

func (*Config) SetProjectedFields

func (conf *Config) SetProjectedFields(fields []string)

func (*Config) String

func (conf *Config) String() string

type Format

type Format int
const (
	CSV Format = iota
	JSON
)

type Mode

type Mode int
const (
	APPEND Mode = iota
	OVERWRITE
)

Jump to

Keyboard shortcuts

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