format

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package formt defines utilities for formatting Struct field values

Index

Constants

View Source
const (
	TagName = "format"
)

Variables

This section is empty.

Functions

func IsValidTagKey added in v0.5.0

func IsValidTagKey(key string) bool

Types

type Tag

type Tag struct {
	Name string `tag:"name,omitempty"` //source for output name, is case formater is not defined, use Name otherwise use Name in UpperCamel format

	CaseFormat string `tag:"caseFormat,omitempty"`

	DateFormat string `tag:"dataFormat,omitempty"`
	TimeLayout string `tag:"timeLayout,omitempty"`
	FormatMask string `tag:"formatMask,omitempty"`
	//Nullable flag to output null value as opposed zero/empty value
	Nullable  *bool `tag:"nullable,omitempty"`
	Inline    bool  `tag:"inline,omitempty"`
	Omitempty bool  `tag:"omitempty,omitempty"`
	Ignore    bool  `tag:"ignore,omitempty"`

	//TBD
	Precision int    `tag:"-"`
	Scale     int    `tag:"-"`
	Language  string `tag:"-"`
	// contains filtered or unexported fields
}

func Parse

func Parse(tag reflect.StructTag, names ...string) (*Tag, error)

func (*Tag) CaseFormatName

func (t *Tag) CaseFormatName(defaultCaseFormat text.CaseFormat) string

func (*Tag) FormatFloat

func (t *Tag) FormatFloat(f float64) (string, error)

func (*Tag) FormatName

func (t *Tag) FormatName() string

func (*Tag) FormatTime

func (t *Tag) FormatTime(ts *time.Time) string

func (*Tag) IsNullable added in v0.5.1

func (t *Tag) IsNullable() bool

func (*Tag) ParseTime added in v0.5.2

func (t *Tag) ParseTime(value string) (time.Time, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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