util

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSolution = fmt.Errorf("no solution")

ErrNoSolution is returned by RenderSize when it can't find a solution.

Functions

func JoinURL

func JoinURL(base, suffix string) (string, error)

JoinURL will join a base URL and suffix, taking care to preserve and merge query parameters.

func LoadLocation

func LoadLocation(name string) (*time.Location, error)

LoadLocation works like time.LoadLocation but caches the result for the life of the process.

func RenderSize added in v0.30.0

func RenderSize(maxSize int, input string, renderFunc func(string) (string, error)) (string, error)

RenderSize will return the rendered result as close as possible to the max size.

func RenderSizeN added in v0.30.0

func RenderSizeN(maxSize int, inputs []string, renderFunc func([]string) (string, error)) (result string, err error)

RenderSizeN works like RenderSize but accepts multiple inputs.

Inputs are trimmed one by one starting with the fist element.

Types

type ContextPreparer

type ContextPreparer interface {
	PrepareContext(context.Context, string) (*sql.Stmt, error)
}

type Prepare

type Prepare struct {
	DB  Preparer
	Ctx context.Context
	Err error
}

Prepare is used to prepare SQL statements.

If Ctx is specified, it will be used to prepare all statements. Only the first error is recorded. Subsequent calls to `P` are ignored after a failure.

func (*Prepare) P

func (p *Prepare) P(query string) (s *sql.Stmt)

type PrepareStmt

type PrepareStmt struct {
	*sql.Stmt
	// contains filtered or unexported fields
}

func (*PrepareStmt) PrepareFor

func (p *PrepareStmt) PrepareFor(ctx context.Context, cp ContextPreparer) (*sql.Stmt, error)

type Preparer

type Preparer interface {
	PrepareContext(context.Context, string) (*sql.Stmt, error)
}

type QueryError

type QueryError interface {
	Query() string
	Cause() *sqlutil.Error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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