config

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 7 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToString

func ConvertToString(in interface{}, tagType ...string) (s string, err error)

ConvertToString convert struct to string

func ConvertToStringWithTitle

func ConvertToStringWithTitle(in interface{}, title string, tagType ...string) (s string, err error)

ConvertToStringWithTitle convert struct to string with given title

func WriteToBuffer

func WriteToBuffer(in interface{}, buffer *bytes.Buffer, tagType ...string) (err error)

WriteToBuffer loops each member of given input struct recursively, converts member variable names and concerning values to "key = value" string, and then write the string into buffer, it follows some rules:

  1. if tag type is specified, which is optional, "key" will be replaced by the tag name
  2. toml and ini type config files requires each key should has a value(but could be empty), but some toml/ini like config files(for example: my.cnf) allows variables are only keys instead of key value pairs, (for example: skip-name-resolve), in this case, you can specify constant.DefaultRandomString or constant.DefaultRandomInt to those keys not having values, therefore when this function find out those constant values, it will convert to key string ignore the value and also the equal mark

Types

type ErrMessage added in v0.2.2

type ErrMessage struct {
	Header  string
	ErrCode int
	Raw     string
}

func NewErrMessage added in v0.2.2

func NewErrMessage(header string, errCode int, raw string) *ErrMessage

NewErrMessage is an exported alias of newErrMessage() function

func (*ErrMessage) Clone added in v0.2.2

func (e *ErrMessage) Clone() *ErrMessage

Clone returns a new *ErrMessage with same member variables

func (*ErrMessage) Code added in v0.2.2

func (e *ErrMessage) Code() string

Code returns combined Header and ErrCode string

func (*ErrMessage) Error added in v0.2.2

func (e *ErrMessage) Error() string

Error is an implementation fo Error interface

func (*ErrMessage) ErrorOrNil added in v0.2.2

func (e *ErrMessage) ErrorOrNil() error

ErrorOrNil returns an error interface if both Header and ErrCode are not zero value, otherwise, returns nil. This function is useful at the end of accumulation to make sure that the value returned represents the existence of errors

func (*ErrMessage) Renew added in v0.2.2

func (e *ErrMessage) Renew(ins ...interface{}) *ErrMessage

Renew returns a new *ErrMessage and specify with given input

func (*ErrMessage) Specify added in v0.2.2

func (e *ErrMessage) Specify(ins ...interface{})

Specify specifies place holders with given data

func (*ErrMessage) String added in v0.2.20

func (e *ErrMessage) String() string

String is an alias of Error()

Jump to

Keyboard shortcuts

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