format

package
v2.10.0-pre Latest Latest
Warning

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

Go to latest
Published: May 9, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BruteForceIndentation added in v2.8.0

func BruteForceIndentation(ctx context.Context, startIndentation string, cfg Configuration, input io.Reader) (io.Reader, error)

func BuildTabWriter added in v2.1.0

func BuildTabWriter(writer io.Writer) *tabwriter.Writer

func Format

func Format(ctx context.Context, provider Provider, cfg ConfigurationProvider, filename string, fle io.Reader) (io.Reader, error)

func FormatSimple added in v2.9.0

func FormatSimple(ctx context.Context, provider Provider, filename string, useTabs bool, indentSize int, input io.Reader) (io.Reader, error)

func FormatSimpleBytes added in v2.9.0

func FormatSimpleBytes(ctx context.Context, provider Provider, filename string, useTabs bool, indentSize int, input []byte) ([]byte, error)

func HasShebang added in v2.8.0

func HasShebang(bs []byte) bool

HasShebang reports whether bs begins with a valid shell shebang. It supports variations with /usr and env.

func Shebang added in v2.8.0

func Shebang(bs []byte) string

Shebang parses a "#!" sequence from the beginning of the input bytes, and returns the shell that it points to.

For instance, it returns "sh" for "#!/bin/sh", and "bash" for "#!/usr/bin/env bash".

Types

type Configuration

type Configuration interface {
	UseTabs() bool
	IndentSize() int
	Raw() map[string]string
}

func NewBasicConfigurationProvider

func NewBasicConfigurationProvider(tabs bool, indentSize int) Configuration

type ConfigurationProvider

type ConfigurationProvider interface {
	GetConfigurationForFileType(ctx context.Context, filename string) (Configuration, error)
}

func NewDefaultConfigurationProvider added in v2.7.2

func NewDefaultConfigurationProvider() ConfigurationProvider

type LazyFormatProvider added in v2.9.0

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

func NewLazyFormatProvider added in v2.9.0

func NewLazyFormatProvider(providerFunc func() Provider) *LazyFormatProvider

func (*LazyFormatProvider) Format added in v2.9.0

func (p *LazyFormatProvider) Format(ctx context.Context, cfg Configuration, reader io.Reader) (io.Reader, error)

type Provider

type Provider interface {
	Format(ctx context.Context, cfg Configuration, reader io.Reader) (io.Reader, error)
}

Jump to

Keyboard shortcuts

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