options

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	JSONExt  string = ".json"
	WireExt  string = ".wire"
	TextExt  string = ".text"
	ExcelExt string = ".xlsx"
	CSVExt   string = ".csv"
	XMLExt   string = ".xml"
)

Variables

This section is empty.

Functions

func Format2Ext added in v0.8.1

func Format2Ext(fmt Format) (string, error)

Types

type Format

type Format int
const (
	UnknownFormat Format = iota
	JSON
	Wire
	Text
	Excel
	CSV
	XML
)

file format

func Ext2Format

func Ext2Format(ext string) (Format, error)

type HeaderOption

type HeaderOption struct {
	Namerow int32
	Typerow int32
	Noterow int32
	Datarow int32

	Nameline int32
	Typeline int32
}

type InputOption

type InputOption struct {
	Format Format
}

type Option

type Option func(*Options)

Option is the functional option type.

func Header(o *HeaderOption) Option

func Imports

func Imports(imports []string) Option

func Input

func Input(o *InputOption) Option

func LocationName

func LocationName(o string) Option

func LogLevel

func LogLevel(level string) Option

func Output

func Output(o *OutputOption) Option

func Workbook

func Workbook(wb string) Option

func Worksheet

func Worksheet(ws string) Option

type Options

type Options struct {
	LocationName string        // Location represents the collection of time offsets in use in a geographical area. Default is "Asia/Shanghai".
	LogLevel     string        // Log level: debug, info, warn, error
	Header       *HeaderOption // header rows of excel file.
	Output       *OutputOption // output settings.
	Input        *InputOption  // input settings.
	Imports      []string      // imported common proto file paths
	Workbook     string        // workbook path or name
	Worksheet    string        // worksheet name
}

Options is the wrapper of tableau params. Options follow the design of Functional Options (https://github.com/tmrts/go-patterns/blob/master/idiom/functional-options.md).

func ParseOptions

func ParseOptions(setters ...Option) *Options

type OutputOption

type OutputOption struct {
	// only for protogen generated protoconf file
	FilenameWithSubdirPrefix bool // default true, filename dir separator `/` or `\` is replaced by "__"
	FilenameSuffix           string

	// only for confgen generated JSON/Text/Wire file
	FilenameAsSnakeCase bool   // default false, output filename as snake case, default is camel case same as the protobuf message name.
	Format              Format // output pretty format, with mulitline and indent.
	Pretty              bool   // default true, output format: json, text, or wire, and default is json.
	// Output.EmitUnpopulated specifies whether to emit unpopulated fields. It does not
	// emit unpopulated oneof fields or unpopulated extension fields.
	// The JSON value emitted for unpopulated fields are as follows:
	//  ╔═══════╤════════════════════════════╗
	//  ║ JSON  │ Protobuf field             ║
	//  ╠═══════╪════════════════════════════╣
	//  ║ false │ proto3 boolean fields      ║
	//  ║ 0     │ proto3 numeric fields      ║
	//  ║ ""    │ proto3 string/bytes fields ║
	//  ║ null  │ proto2 scalar fields       ║
	//  ║ null  │ message fields             ║
	//  ║ []    │ list fields                ║
	//  ║ {}    │ map fields                 ║
	//  ╚═══════╧════════════════════════════╝
	EmitUnpopulated bool // default true
}

Jump to

Keyboard shortcuts

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