common

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "v0.2.4 20210716"

Version 版本信息

Functions

func DoNotEdit added in v0.1.20200313

func DoNotEdit(src []byte) bool

DoNotEdit 该代码是否不让修改,一般是有代码工具自动生成

func GitChangeFiles added in v0.2.0

func GitChangeFiles() ([]string, error)

GitChangeFiles 获取当前git项目有变更的文件 支持如下git状态: M auth/md5_sign.go R utils/counter_test.go -> component/counter/counter_test.go A unittest/internal/monitor/bvar.apis_monitor.data ?? internal/gofmt/files.go

func ParseFile

func ParseFile(fileName string, src []byte) (fileSet *token.FileSet, file *ast.File, err error)

ParseFile 解析为astFile

func PrintCode

func PrintCode(fileSet *token.FileSet, file *ast.File) (out []byte, err error)

PrintCode 输出代码

Types

type ImportGroupFunc added in v0.2.0

type ImportGroupFunc func(importPath string, opt *Options) int

ImportGroupFunc import 排序逻辑

type Options

type Options struct {
	Trace bool

	TabIndent bool

	TabWidth int

	// LocalPrefix 当前模块的前缀
	LocalPrefix string

	// Write 是否直接将格式化后的内容写入文件
	Write bool

	// 待处理的文件列表
	Files []string

	ImportGroupFn ImportGroupFunc

	// 是否将多段 import 合并为一个
	MergeImports bool

	// SingleLineCopyright 是否将 copyright 的多行注释格式化为单行注释
	SingleLineCopyright bool
}

Options 选项

func NewDefaultOptions added in v0.2.0

func NewDefaultOptions() *Options

NewDefaultOptions 生成默认的 options

func (*Options) AllGoFiles added in v0.2.0

func (opt *Options) AllGoFiles() ([]string, error)

AllGoFiles 获取所有的待格式化的 .go 文件

func (*Options) BindFlags added in v0.2.0

func (opt *Options) BindFlags()

BindFlags 绑定参数信息

Jump to

Keyboard shortcuts

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