utils

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateFormatHyphenYearMonthDay                 = "2006-01-02"
	DateFormatHyphenYearMonthDayHourMinuteSecond = "2006-01-02 15:04:05"
	DateFormatHyphenMonthDayYear                 = "01-02-2006"
	DateFormatHyphenMonthDayYearHourMinuteSecond = "01-02-2006 15:04:05"
	DateFormatHyphenDayMonthYear                 = "02-01-2006"
	DateFormatHyphenDayMonthYearHourMinuteSecond = "02-01-2006 15:04:05"
	DateFormatHyphenMonthDay                     = "01-02"
	DateFormatHyphenDayMonth                     = "02-01"

	DateFormatSlashYearMonthDay                 = "2006/01/02"
	DateFormatSlashYearMonthDayHourMinuteSecond = "2006/01/02 15:04:05"
	DateFormatSlashMonthDayYear                 = "01/02/2006"
	DateFormatSlashMonthDayYearHourMinuteSecond = "01/02/2006 15:04:05"
	DateFormatSlashDayMonthYear                 = "02/01/2006"
	DateFormatSlashDayMonthYearHourMinuteSecond = "02/01/2006 15:04:05"
	DateFormatSlashMonthDay                     = "01/02"
	DateFormatSlashDayMonth                     = "02/01"

	DateFormatYear             = "2006"
	DateFormatHourMinuteSecond = "15:04:05"

	DateConvertUTCToJSTOffset = 9 * 60 * 60
)

Variables

This section is empty.

Functions

func CheckStringCount

func CheckStringCount(str string, maxLen int) bool

CheckStringCount checks if the specified string length has been exceeded.

func ConvertJSTToUTC added in v0.0.19

func ConvertJSTToUTC(t time.Time) time.Time

ConvertJSTToUTC converts JST to UTC

func ConvertToString

func ConvertToString(input interface{}) (string, error)

ConvertToString converts a basic type to a string type.

func ConvertUTCToJST added in v0.0.19

func ConvertUTCToJST(t time.Time) time.Time

ConvertUTCToJST converts UTC to JST

func GetBufferFromReadCloser

func GetBufferFromReadCloser(r io.ReadCloser) ([]byte, error)

GetBufferFromReadCloser gets buffer

func GetDateFormatString added in v0.0.19

func GetDateFormatString(t time.Time, format string) string

GetDateFormatString gets format date string.

func GetDateTime added in v0.0.19

func GetDateTime(str, format string) (time.Time, error)

GetDateTime gets time.

func GetMySQLDsn

func GetMySQLDsn(username, password, server, port, db, parameter string) string

GetMySQLDsn creates a MySQL DSN string. about DSN document. https://github.com/go-sql-driver/mysql#dsn-data-source-name

func GetPostgresDsn

func GetPostgresDsn(user, password, host, port, dbname, parameter string) string

GetPostgresDsn creates a Postgres DSN string.

func GetStringCount

func GetStringCount(str string) int

GetStringCount gets the number of characters in a person's view.

func GetStringFromReadCloser

func GetStringFromReadCloser(r io.ReadCloser) (string, error)

GetStringFromReadCloser gets string

func SliceUTF8

func SliceUTF8(str string, pos int) string

SliceUTF8 gets the characters from the beginning to the specified position, in UTF-8-based characters.

func SliceUTF8AddString

func SliceUTF8AddString(str string, pos int, addString string) string

SliceUTF8AddString gets the characters from the beginning to the specified position, in UTF-8-based characters.

func TransactionGorm

func TransactionGorm(db *gorm.DB, f func(db *gorm.DB) error) error

TransactionGorm automatically performs transactions (Begin/Commit/Rollback) between specified func...

Types

This section is empty.

Jump to

Keyboard shortcuts

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