format.go 183 B

123456789101112
  1. package golang
  2. import goformat "go/format"
  3. func FormatCode(code string) string {
  4. ret, err := goformat.Source([]byte(code))
  5. if err != nil {
  6. return code
  7. }
  8. return string(ret)
  9. }