Fix provider review findings
This commit is contained in:
@@ -4,7 +4,6 @@ package helpers
|
||||
import (
|
||||
"fmt"
|
||||
"go/format"
|
||||
"os"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
@@ -168,14 +167,13 @@ func EnsureGoIdent(s string) string {
|
||||
return "R" + s
|
||||
}
|
||||
|
||||
// FormatSourceOrWarn форматирует Go-код. При ошибке пишет warning в stderr.
|
||||
func FormatSourceOrWarn(filePath string, src []byte) []byte {
|
||||
// FormatSourceOrWarn форматирует Go-код и возвращает ошибку при сбое gofmt.
|
||||
func FormatSourceOrWarn(filePath string, src []byte) ([]byte, error) {
|
||||
formatted, err := format.Source(src)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: gofmt failed for %s: %v — writing unformatted code\n", filePath, err)
|
||||
return src
|
||||
return nil, fmt.Errorf("gofmt failed for %s: %w", filePath, err)
|
||||
}
|
||||
return formatted
|
||||
return formatted, nil
|
||||
}
|
||||
|
||||
// PlanModifierType возвращает суффикс типа план-модификатора (Bool/Int64/String).
|
||||
|
||||
Reference in New Issue
Block a user