Help us shape the future of Go! Take the 2026 Go Developer Survey

format

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 13

Documentation

Overview

Package formt defines utilities for formatting Struct field values

Index

Constants

View Source
const (
	//TagName defines format tag name
	TagName = "format"
)

Variables

This section is empty.

Functions

func IsValidTagKey

func IsValidTagKey(key string) bool

IsValidTagKey returns true if value key

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"`
	Timezone   string `tag:"timezone,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
}

Tag defines format tag

func Parse

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

Parse parses format tag

func (*Tag) CaseFormatName

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

CaseFormatName returns case formatted name

func (*Tag) FormatName

func (t *Tag) FormatName() string

FormatName formata name

func (*Tag) FormatTime

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

FormatTime formats time

func (*Tag) IsNullable

func (t *Tag) IsNullable() bool

IsNullable returns true if nullable

func (*Tag) ParseTime

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

ParseTime parses time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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