gofmt

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OnExecute = func(opt *Options) error {
	return nil
}

OnExecute hook Before Execute

Functions

func Format

func Format(fileName string, src []byte, opts *Options) (code []byte, formatted bool, err error)

Format 输出格式化的 go 代码

func FormatComments

func FormatComments(req *common.Request)

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

Types

type Formatter added in v0.2.0

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

Formatter 代码格式化实例

func NewFormatter added in v0.2.0

func NewFormatter() *Formatter

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

func (*Formatter) Execute added in v0.2.0

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

Execute 执行代码格式化

func (*Formatter) Format added in v0.2.0

func (ft *Formatter) Format(fileName string, src []byte, opt *Options) (origin []byte, pretty []byte, formatted bool, err error)

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

func (*Formatter) FormatAndWriteFile added in v0.2.0

func (ft *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