diff --git a/bfcodegen/csid-generate.go b/bfcodegen/csid-generate.go index c92422e..d7938f0 100644 --- a/bfcodegen/csid-generate.go +++ b/bfcodegen/csid-generate.go @@ -5,8 +5,8 @@ import ( _ "embed" "errors" "fmt" + "go/format" "gogs.mikescher.com/BlackForestBytes/goext" - "gogs.mikescher.com/BlackForestBytes/goext/cmdext" "gogs.mikescher.com/BlackForestBytes/goext/cryptext" "gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/rext" @@ -17,7 +17,6 @@ import ( "regexp" "strings" "text/template" - "time" ) type CSIDDef struct { @@ -101,25 +100,16 @@ func GenerateCharsetIDSpecs(sourceDir string, destFile string) error { return errors.New("no package name found in any file") } - err = os.WriteFile(destFile, []byte(fmtCSIDOutput(newChecksum, allIDs, pkgname)), 0o755) + fdata, err := format.Source([]byte(fmtCSIDOutput(newChecksum, allIDs, pkgname))) if err != nil { return err } - res, err := cmdext.RunCommand("go", []string{"fmt", destFile}, langext.Ptr(2*time.Second)) + err = os.WriteFile(destFile, fdata, 0o755) if err != nil { return err } - if res.CommandTimedOut { - fmt.Println(res.StdCombined) - return errors.New("go fmt timed out") - } - if res.ExitCode != 0 { - fmt.Println(res.StdCombined) - return errors.New("go fmt did not succeed") - } - return nil } diff --git a/bfcodegen/enum-generate.go b/bfcodegen/enum-generate.go index cee3c53..3d6e3be 100644 --- a/bfcodegen/enum-generate.go +++ b/bfcodegen/enum-generate.go @@ -5,8 +5,8 @@ import ( _ "embed" "errors" "fmt" + "go/format" "gogs.mikescher.com/BlackForestBytes/goext" - "gogs.mikescher.com/BlackForestBytes/goext/cmdext" "gogs.mikescher.com/BlackForestBytes/goext/cryptext" "gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/rext" @@ -17,7 +17,6 @@ import ( "regexp" "strings" "text/template" - "time" ) type EnumDefVal struct { @@ -110,25 +109,16 @@ func GenerateEnumSpecs(sourceDir string, destFile string) error { return errors.New("no package name found in any file") } - err = os.WriteFile(destFile, []byte(fmtEnumOutput(newChecksum, allEnums, pkgname)), 0o755) + fdata, err := format.Source([]byte(fmtEnumOutput(newChecksum, allEnums, pkgname))) if err != nil { return err } - res, err := cmdext.RunCommand("go", []string{"fmt", destFile}, langext.Ptr(2*time.Second)) + err = os.WriteFile(destFile, fdata, 0o755) if err != nil { return err } - if res.CommandTimedOut { - fmt.Println(res.StdCombined) - return errors.New("go fmt timed out") - } - if res.ExitCode != 0 { - fmt.Println(res.StdCombined) - return errors.New("go fmt did not succeed") - } - return nil } diff --git a/bfcodegen/id-generate.go b/bfcodegen/id-generate.go index 951b579..d83edd4 100644 --- a/bfcodegen/id-generate.go +++ b/bfcodegen/id-generate.go @@ -5,8 +5,8 @@ import ( _ "embed" "errors" "fmt" + "go/format" "gogs.mikescher.com/BlackForestBytes/goext" - "gogs.mikescher.com/BlackForestBytes/goext/cmdext" "gogs.mikescher.com/BlackForestBytes/goext/cryptext" "gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/rext" @@ -17,7 +17,6 @@ import ( "regexp" "strings" "text/template" - "time" ) type IDDef struct { @@ -100,25 +99,16 @@ func GenerateIDSpecs(sourceDir string, destFile string) error { return errors.New("no package name found in any file") } - err = os.WriteFile(destFile, []byte(fmtIDOutput(newChecksum, allIDs, pkgname)), 0o755) + fdata, err := format.Source([]byte(fmtIDOutput(newChecksum, allIDs, pkgname))) if err != nil { return err } - res, err := cmdext.RunCommand("go", []string{"fmt", destFile}, langext.Ptr(2*time.Second)) + err = os.WriteFile(destFile, fdata, 0o755) if err != nil { return err } - if res.CommandTimedOut { - fmt.Println(res.StdCombined) - return errors.New("go fmt timed out") - } - if res.ExitCode != 0 { - fmt.Println(res.StdCombined) - return errors.New("go fmt did not succeed") - } - return nil } diff --git a/goextVersion.go b/goextVersion.go index eac0980..f06b348 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.297" +const GoextVersion = "0.0.298" -const GoextVersionTimestamp = "2023-11-01T00:31:51+0100" +const GoextVersionTimestamp = "2023-11-01T04:20:08+0100"