format

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FixNone says to not do fixing.
	FixNone = 0
	// FixV1 says to do V1 fixing.
	FixV1 = 1
	// FixV2 says to do V2 fixing.
	FixV2 = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Transformer

type Transformer interface {
	// Transform transforms the data.
	//
	// Failures should never happen in the CLI tool as we run the files
	// through protoc first, but this is done because we want to verify
	// code correctness here and protect against the bad case.
	Transform(filename string, data []byte) ([]byte, []*text.Failure, error)
}

Transformer transforms an input file into an output file.

func NewTransformer

func NewTransformer(options ...TransformerOption) Transformer

NewTransformer returns a new Transformer.

type TransformerOption

type TransformerOption func(*transformer)

TransformerOption is an option for a new Transformer.

func TransformerWithFileHeader added in v1.4.0

func TransformerWithFileHeader(fileHeader string) TransformerOption

TransformerWithFileHeader returns a TransformerOption that will update the file header to match the given file header.

This is only valid if fix is set to a value other than FixNone.

func TransformerWithFix added in v0.6.0

func TransformerWithFix(fix int) TransformerOption

TransformerWithFix returns a TransformerOption that will update the file options to match the package per the guidelines of the style guide.

func TransformerWithJavaPackagePrefix added in v1.4.0

func TransformerWithJavaPackagePrefix(javaPackagePrefix string) TransformerOption

TransformerWithJavaPackagePrefix returns a TransformerOption that will override the Java package prefix.

This is only valid if fix is set to a value other than FixNone.

func TransformerWithLogger

func TransformerWithLogger(logger *zap.Logger) TransformerOption

TransformerWithLogger returns a TransformerOption that uses the given logger.

The default is to use zap.NewNop().

Jump to

Keyboard shortcuts

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