tecutils

package
v0.0.0-...-dd30ea9 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 19 Imported by: 0

README

tecutils

Misc utils functions I used on my own golang projects

Build Status

Documentation

Index

Constants

View Source
const (
	DATE_FORMAT      = "02-01-2006"
	DATE_TIME_FORMAT = "02-01-2006 15:04"
)

fixed date formats

View Source
const (
	DEFAULT_PERMISSION = 0777
)

Variables

This section is empty.

Functions

func Clone

func Clone(s, t interface{}) (interface{}, error)

func CreateDirectoryIfNotExist

func CreateDirectoryIfNotExist(fullpath string) (err error)

Verifies if the directory already exists, if it does not then it is created

func DbSize

func DbSize(tx gorp.SqlExecutor, dbName string) (string, error)

func DirectoryExists

func DirectoryExists(fullpath string) (ok bool)

Returns true if the directory exists

func Encrypt

func Encrypt(text string) (result string)

func FileDaysOld

func FileDaysOld(f *os.FileInfo) int

func FormatCurrency

func FormatCurrency(n float64) string

func FormatCurrencyZero

func FormatCurrencyZero(n float64) string

func FormatDate

func FormatDate(d *time.Time) string

func FormatDateTime

func FormatDateTime(d *time.Time) string

func FormatFloat

func FormatFloat(n float64) string

func FormatInt

func FormatInt(n float64) string

func FormatPercent

func FormatPercent(n float64) string

func FormatPercentWithZeroes

func FormatPercentWithZeroes(n float64) string

func GetPackageFullPath

func GetPackageFullPath(name string) (result string, err error)

Devuelve la ruta local de un package de go

func ParseBaseUrl

func ParseBaseUrl(urlAddress string) (parsed string, err error)

Devuelve la url base de una direccion http o https

func ProcessDirectoryContents

func ProcessDirectoryContents(fullpath string, recursive bool, fn FileLambda, level int) (err error)

Reads a directory content recursively and process the lambda code inside

func RenderFloat

func RenderFloat(format string, n float64) string

func RenderInteger

func RenderInteger(format string, n int) string

func Split

func Split(text string, sep string) []string

splits a string based on sep char removes empty elements

func SplitUnique

func SplitUnique(text string, sep string) []string

func TableToText

func TableToText(headers, body []string, separator string) (string, error)

given an array of cells, return as formatted text each element of body is a row and each cell has a separator

func TruncMs

func TruncMs(d *time.Time, loc *time.Location)

func TruncMsUTC

func TruncMsUTC(d *time.Time)

func UUID

func UUID() string

func Unzip

func Unzip(archive, target string) error

func Zip

func Zip(source, target string) error

Types

type DbTableInfo

type DbTableInfo struct {
	TableName string `json:"tableName"`
	Bytes     int64  `json:"bytes"`
}

func TablesInfo

func TablesInfo(tx gorp.SqlExecutor) (items []DbTableInfo, err error)

type FileInfo

type FileInfo struct {
	Name  string
	Size  int64
	IsDir bool
}

type FileLambda

type FileLambda func(fullpath string, info *FileInfo, level int)

type Subdirectory

type Subdirectory struct {
	Name      string `json:"name"`
	FileCount int64  `json:"fileCount"`
	Bytes     int64  `json:"bytes"`
}

func SubdirectoriesInfo

func SubdirectoriesInfo(root string) (dirs []*Subdirectory, err error)

Jump to

Keyboard shortcuts

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