misc

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Funciones misceláneas

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInterval added in v2.2.0

func AddInterval(t pgtype.Timestamp, i pgtype.Interval) (result pgtype.Timestamp)

Añade un pgtype.Interval a un pgtype.Timestamp

Example
unDia := pgtype.Interval{Days: 1, Valid: true}
fechaInicial, err := formato.ParseTimestamp("4/7/2023 12:00", formato.DMA)
errores.PanicIfError(err)
fechaSiguiente := AddInterval(fechaInicial, unDia)
fmt.Println(formato.PrintTimestamp(fechaSiguiente, formato.DMA))
Output:

05/07/2023 12:00

func EscapeSQL

func EscapeSQL(s string) string

Escapa un texto para su uso en órdenes SQL

Example
sql := `select * from tabla where nombre=` + EscapeSQL("O'Brian")
fmt.Println(sql)
Output:

select * from tabla where nombre='O''Brian'

func GetGID added in v2.4.0

func GetGID() int64

Obtiene el ID de la goroutine actual

func Max

func Max[T constraints.Ordered](v ...T) T

Halla el máximo de una lista

Example
fmt.Println(Max(-2, 3, 1))
Output:

3

func Min

func Min[T constraints.Ordered](v ...T) T

Halla el mínimo de una lista

Example
fmt.Println(Min(3, -2, 3, 1))
Output:

-2

func SqlIn

func SqlIn(valores ...string) string

Compone parte de una clausula WHERE CAMPO IN (VALORES...) Devuelve "in (VALORES...)" o "= VALOR" o "is null"

Example
codigos := []string{"cero", "uno", "dos", "tres"}
sql := `select * from tabla where codigo` + SqlIn(codigos[1:]...)
fmt.Println(sql)
Output:

select * from tabla where codigo in ('uno','dos','tres')

func SubInterval added in v2.2.0

func SubInterval(t pgtype.Timestamp, i pgtype.Interval) (result pgtype.Timestamp)

Sustrae un pgtype.Interval de un pgtype.Timestamp

Example
unDia := pgtype.Interval{Days: 1, Valid: true}
fechaInicial, err := formato.ParseTimestamp("4/7/2023 12:00", formato.DMA)
errores.PanicIfError(err)
fechaAnterior := SubInterval(fechaInicial, unDia)
fmt.Println(formato.PrintTimestamp(fechaAnterior, formato.DMA))
Output:

03/07/2023 12:00

func Title

func Title(s string) string

Hace lo mismo que la deprecada strings.Title: pasar la primera letra a mayúsculas

Example
fmt.Println(Title("hola mundo otra vEZ"))
Output:

Hola Mundo Otra VEZ

Types

This section is empty.

Jump to

Keyboard shortcuts

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