MCPcopy
hub / github.com/swaggo/swag / format

Method format

format/format.go:95–111  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

93}
94
95func (f *Format) format(path string) error {
96 original, err := os.ReadFile(path)
97 if err != nil {
98 return err
99 }
100 contents := make([]byte, len(original))
101 copy(contents, original)
102 formatted, err := f.formatter.Format(path, contents)
103 if err != nil {
104 return err
105 }
106 if bytes.Equal(original, formatted) {
107 // Skip write if no change
108 return nil
109 }
110 return write(path, formatted)
111}
112
113func write(path string, contents []byte) error {
114 originalFileInfo, err := os.Stat(path)

Callers 1

visitMethod · 0.95

Calls 2

writeFunction · 0.85
FormatMethod · 0.80

Tested by

no test coverage detected