runtime

package
v0.2.793 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 7 Imported by: 763

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBufferSize = 4 * 1024 // 4KB

DefaultBufferSize is the default size of buffers. It is set to 4KB by default, which is the same as the default buffer size of bufio.Writer.

Functions

func GeneratedTemplate

func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component

GeneratedTemplate is used to avoid generated code needing to import the `context` and `io` packages.

func GetBuilder

func GetBuilder() (sb strings.Builder)

GetBuilder returns a strings.Builder.

func ReleaseBuffer

func ReleaseBuffer(w io.Writer) (err error)

ReleaseBuffer flushes the buffer and returns it to the pool.

Types

type Buffer

type Buffer struct {
	Underlying io.Writer
	// contains filtered or unexported fields
}

Buffer is a wrapper around bufio.Writer that enables flushing and closing of the underlying writer.

func GetBuffer

func GetBuffer(w io.Writer) (b *Buffer, existing bool)

GetBuffer creates and returns a new buffer if the writer is not already a buffer, or returns the existing buffer if it is.

func (*Buffer) Close

func (b *Buffer) Close() error

Close closes the buffer and the underlying io.Writer if it implements io.Closer.

func (*Buffer) Flush

func (b *Buffer) Flush() error

Flush writes any buffered data to the underlying io.Writer and calls the Flush method of the underlying http.Flusher if it implements it.

func (*Buffer) Reset

func (b *Buffer) Reset(w io.Writer)

Reset sets the underlying io.Writer to w and resets the buffer.

func (*Buffer) Size

func (b *Buffer) Size() int

Size returns the size of the underlying buffer in bytes.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write the contents of p into the buffer.

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string) (n int, err error)

WriteString writes the contents of s into the buffer.

type GeneratedComponentInput

type GeneratedComponentInput struct {
	Context context.Context
	Writer  io.Writer
}

GeneratedComponentInput is used to avoid generated code needing to import the `context` and `io` packages.

Jump to

Keyboard shortcuts

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