Documentation ¶
Overview ¶
suffixwriter defines the writer that writes to suffixed name along the original files.
Index ¶
- func ApplyGoimports(ctx context.Context, buf []byte) ([]byte, error)
- func CheckGoimports() error
- func IsSuffixed(f, suffix string) bool
- func SuffixFilename(f, suffix string) string
- type Option
- func WithCwd(cwd string) Option
- func WithFileFactory(fileFactory func(name string) (io.WriteCloser, error)) Option
- func WithLogf(logf func(format string, args ...any)) Option
- func WithPostProcess(postProcess PostProcess) Option
- func WithPreProcess(preProcess PreProcess) Option
- func WithPrefix(prefix []byte) Option
- type PostProcess
- type PreProcess
- type TestWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckGoimports ¶
func CheckGoimports() error
func IsSuffixed ¶
IsSuffixed tests f is suffixed with suffix. The test ignores file extension and implicit build constraints suffix in f.
func SuffixFilename ¶
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 WithFileFactory ¶
func WithFileFactory(fileFactory func(name string) (io.WriteCloser, error)) Option
func WithPostProcess ¶
func WithPostProcess(postProcess PostProcess) Option
func WithPreProcess ¶
func WithPreProcess(preProcess PreProcess) Option
func WithPrefix ¶
type PreProcess ¶
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
Click to show internal directories.
Click to hide internal directories.