v0.0.298 use go/format instead of manual command invocation
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m6s

This commit is contained in:
Mike Schwörer 2023-11-01 04:20:08 +01:00
parent dacc97e2ce
commit 678f95642c
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
4 changed files with 11 additions and 41 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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"