MCPcopy
hub / github.com/flipped-aurora/gin-vue-admin / Format

Method Format

server/utils/ast/interfaces_base.go:42–60  ·  view source on GitHub ↗
(filename string, writer io.Writer, file *ast.File)

Source from the content-addressed store, hash-verified

40}
41
42func (a *Base) Format(filename string, writer io.Writer, file *ast.File) error {
43 fileSet := a.FileSet
44 if fileSet == nil {
45 fileSet = token.NewFileSet()
46 }
47 if writer == nil {
48 open, err := os.OpenFile(filename, os.O_WRONLY|os.O_TRUNC, 0666)
49 defer open.Close()
50 if err != nil {
51 return errors.Wrapf(err, "[filepath:%s]打开文件失败!", filename)
52 }
53 writer = open
54 }
55 err := format.Node(writer, fileSet, file)
56 if err != nil {
57 return errors.Wrapf(err, "[filepath:%s]注入失败!", filename)
58 }
59 return nil
60}
61
62// RelativePath 绝对路径转相对路径
63func (a *Base) RelativePath(filePath string) string {

Callers

nothing calls this directly

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected