MCPcopy Index your code
hub / github.com/TheThingsNetwork/lorawan-stack / Fmt

Method Fmt

tools/mage/sql.go:39–59  ·  view source on GitHub ↗

Fmt formats all .sql files

(context.Context)

Source from the content-addressed store, hash-verified

37
38// Fmt formats all .sql files
39func (SQL) Fmt(context.Context) error {
40 wd, err := os.Getwd()
41 if err != nil {
42 return fmt.Errorf("failed to get working directory: %w", err)
43 }
44 err = sh.Run("docker", "run",
45 "--rm",
46 "-e", "SQLFMT_LINE_LENGTH="+lineLength,
47 "-v", fmt.Sprintf("%s:/src", wd),
48 sqlfmtImage)
49 if err != nil {
50 fmt.Println("returning here")
51 return err
52 }
53 // Scan all files to replace '-- bun:split' with '--bun:split
54 err = walkDir(wd, fixBunSplit)
55 if err != nil {
56 return err
57 }
58 return nil
59}
60
61func walkDir(root string, apply func(path string, filename string) error) error {
62 files, err := os.ReadDir(root)

Callers

nothing calls this directly

Calls 3

walkDirFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected