gofmt

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(fileName string, src []byte, options *Options) ([]byte, error)

Format 输出格式化的go代码

func FormatComments

func FormatComments(fileSet *token.FileSet, f *ast.File, options *Options)

FormatComments 对代码注释进行格式化 若是空行注释将删除

Types

type Formatter added in v0.2.0

type Formatter struct {
	// PrintResult 用于格式化过程中,打印结果
	PrintResult func(fileName string, change bool, err error)
}

Formatter 代码格式化实例

func NewFormatter added in v0.2.0

func NewFormatter() *Formatter

NewFormatter 创建一个新的带默认格式化规则的格式化实例

func (*Formatter) Execute added in v0.2.0

func (gf *Formatter) Execute(opt *Options) error

Execute 执行代码格式化

func (*Formatter) Format added in v0.2.0

func (gf *Formatter) Format(fileName string, src []byte, opt *Options) (out []byte, change bool, err error)

Format 格式化文件,获取格式化后的内容

func (*Formatter) FormatAndWriteFile added in v0.2.0

func (gf *Formatter) FormatAndWriteFile(fileName string, opt *Options) (bool, error)

FormatAndWriteFile 格式化并写入文件

type Options

type Options = common.Options

Options 别名

Jump to

Keyboard shortcuts

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