shorten

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxLen          int    // Max target width for each line
	TabLen          int    // Width of a tab character
	KeepAnnotations bool   // Whether to keep annotations in the final result (for debugging only)
	ShortenComments bool   // Whether to shorten comments
	ReformatTags    bool   // Whether to reformat struct tags in addition to shortening long lines
	DotFile         string // Path to write dot-formatted output to (for debugging only)
	ChainSplitDots  bool   // Whether to split chain methods by putting dots at the ends of lines
}

Config stores the configuration options exposed by a Shortener instance.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns a Config with default values.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
}

type Options

type Options func(*Shortener)

Options is the type for configuring options of a Shortener instance.

func WithLogger

func WithLogger(logger Logger) Options

WithLogger sets the logger to use it for a Shortener instance.

type Shortener

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

Shortener shortens a single go file according to a small set of user style preferences.

func NewShortener

func NewShortener(config *Config, opts ...Options) *Shortener

NewShortener creates a new shortener instance from the provided config.

func (*Shortener) Process

func (s *Shortener) Process(content []byte) ([]byte, error)

Process shortens the provided golang file content bytes.

Directories

Path Synopsis
internal
generate command
Package main is used to generate code that creates dot files from golang ASTs.
Package main is used to generate code that creates dot files from golang ASTs.

Jump to

Keyboard shortcuts

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