utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

func EstimateTokens

func EstimateTokens(text string) int64

func ExpandSliceToFit

func ExpandSliceToFit[T any](slice []T, index int) []T

func JsonSchemaResolve

func JsonSchemaResolve[T any]() (*jsonschema.Resolved, string, error)

func JsonSchemaValidate

func JsonSchemaValidate(resolved *jsonschema.Resolved, str string, result any) error

func Ptr

func Ptr[T any](v T) *T

Types

type IntOrInf

type IntOrInf int

IntOrInf is a type that can be either an int or "inf".

const (
	// Inf is the maximum value for an IntOrInf.
	Inf IntOrInf = math.MaxInt
)

func (IntOrInf) IsInf

func (m IntOrInf) IsInf() bool

IsInf returns true if the value is "inf".

func (IntOrInf) MarshalJSON

func (m IntOrInf) MarshalJSON() ([]byte, error)

MarshalJSON marshals the IntOrInf to JSON.

func (*IntOrInf) UnmarshalJSON

func (m *IntOrInf) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the IntOrInf from JSON.

type WriterSeeker

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

WriterSeeker is an in-memory io.WriteSeeker implementation

func (*WriterSeeker) BytesReader

func (ws *WriterSeeker) BytesReader() *bytes.Reader

BytesReader returns a *bytes.Reader. Use it when you need a reader that implements the io.ReadSeeker interface

func (*WriterSeeker) Close

func (ws *WriterSeeker) Close() error

Close :

func (*WriterSeeker) Reader

func (ws *WriterSeeker) Reader() io.Reader

Reader returns an io.Reader. Use it, for example, with io.Copy, to copy the content of the WriterSeeker buffer to an io.Writer

func (*WriterSeeker) Seek

func (ws *WriterSeeker) Seek(offset int64, whence int) (int64, error)

Seek seeks in the buffer of this WriterSeeker instance

func (*WriterSeeker) Write

func (ws *WriterSeeker) Write(p []byte) (n int, err error)

Write writes to the buffer of this WriterSeeker instance

Jump to

Keyboard shortcuts

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