util

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigToStruct

func ConfigToStruct[T any](rawConfig map[string]interface{}) *T

Takes an arbitrary map and populates a struct with the fields. Used for transforming configuration files into structs.

func FreeDiskSpace

func FreeDiskSpace(path string) uint64

func GetJSONTypes

func GetJSONTypes(file io.ReadSeeker) (map[string]string, error)

func JsonEscape

func JsonEscape(i string) string

Takes a string and returns a JSON-escaped version

func NewSnowflakeGenerator

func NewSnowflakeGenerator() (*snowflake.Node, error)

func TrimQuery

func TrimQuery(query string) string

Trims whitespace and trailing ; characters from sql

Types

type ChunkedWriter

type ChunkedWriter struct {
	// contains filtered or unexported fields
}

func NewChunkedWriter

func NewChunkedWriter(maxSize int, chunkSize int, folder string) *ChunkedWriter

func (*ChunkedWriter) Close

func (w *ChunkedWriter) Close() error

func (*ChunkedWriter) Write

func (w *ChunkedWriter) Write(data []byte) (int, error)

type StringBuffer

type StringBuffer struct {
	strings.Builder
}

StringBuffer provide various helper methods for working with a strings.Builder

func (*StringBuffer) Printf

func (b *StringBuffer) Printf(f string, a ...any) *StringBuffer

Printf is equivalent to `fmt.Fprintf(b, f, a...)`

func (*StringBuffer) PrintfIf

func (b *StringBuffer) PrintfIf(ok bool, f string, a ...any) *StringBuffer

PrintfIf is equivalent to `if (ok) { b.Printf(f, a...) }`

func (*StringBuffer) Quote

func (b *StringBuffer) Quote(quote rune, escapedQuote string, f string, a ...any) *StringBuffer

Quote prints a quoted string to the buffer with quote's in the input replaced with escapedQuote

It's is equivalent to: > s = Sprintf(f, a...) > s = RecplaceAll(s, quote, escapedQuote) > b.Printf(quote + s + quote)`

func (*StringBuffer) Reset

func (b *StringBuffer) Reset() *StringBuffer

Reset reset the buffer to be empty

func (*StringBuffer) SQLIdent

func (b *StringBuffer) SQLIdent(f string, a ...any) *StringBuffer

SQLIdent prints a (quoted, iff required) SQL identifier to the buffer

func (*StringBuffer) SQLString

func (b *StringBuffer) SQLString(f string, a ...any) *StringBuffer

SQLString prints a quoted SQL string to the buffer

func (*StringBuffer) Space

func (b *StringBuffer) Space() *StringBuffer

Space prints a space to the buffer, it's equivalent to `b.Printf(" ")`

Jump to

Keyboard shortcuts

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