suffixwriter

package
v0.0.0-...-6a0b755 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

suffixwriter defines the writer that writes to suffixed name along the original files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyGoimports

func ApplyGoimports(ctx context.Context, buf []byte) ([]byte, error)

func CheckGoimports

func CheckGoimports() error

func IsSuffixed

func IsSuffixed(f, suffix string) bool

IsSuffixed tests f is suffixed with suffix. The test ignores file extension and implicit build constraints suffix in f.

func SuffixFilename

func SuffixFilename(f, suffix string) string

SuffixFilename suffixes f by suffix. It moves implicit build constraints from original filename to suffix.

For example, assuming passing ".suf" to suffix:

  • foo_linux.go -> foo.suf_linux.go
  • foo_amd64_test.go -> foo.suf_amd64_test.go
  • foo_bar.go -> foo_bar.suf.go

Basically SuffixFilename is intended to be used for ".go" files but actually can be used for any file extension, even no file extension is allowed.

Types

type Option

type Option func(p *Writer)

func WithCwd

func WithCwd(cwd string) Option

func WithFileFactory

func WithFileFactory(fileFactory func(name string) (io.WriteCloser, error)) Option

func WithLogf

func WithLogf(logf func(format string, args ...any)) Option

func WithPostProcess

func WithPostProcess(postProcess PostProcess) Option

func WithPreProcess

func WithPreProcess(preProcess PreProcess) Option

func WithPrefix

func WithPrefix(prefix []byte) Option

type PostProcess

type PostProcess func(ctx context.Context, src []byte) ([]byte, error)

type PreProcess

type PreProcess func(name string) error

type TestWriter

type TestWriter struct {
	*Writer
	// contains filtered or unexported fields
}

func NewTestWriter

func NewTestWriter(suffix string, opts ...Option) *TestWriter

func (*TestWriter) Results

func (p *TestWriter) Results() map[string][]byte

type Writer

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

Writer writes data to suffixed file.

func New

func New(suffix string, opts ...Option) *Writer

func (*Writer) Write

func (p *Writer) Write(ctx context.Context, name string, b []byte) error

Write write b into name but suffixed.

Jump to

Keyboard shortcuts

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