feat: fix format

This commit is contained in:
Kasper Juul Hermansen 2023-04-06 22:33:29 +02:00
parent 8d514ab698
commit 44575dd763
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
2 changed files with 7 additions and 3 deletions

View File

@ -18,7 +18,7 @@ type Opts struct {
type OptsFunc func(ctx context.Context, o *Opts) error type OptsFunc func(ctx context.Context, o *Opts) error
func WithPath(path string) OptsFunc { func withPath(path string) OptsFunc {
return func(ctx context.Context, o *Opts) error { return func(ctx context.Context, o *Opts) error {
o.Path = path o.Path = path
@ -26,7 +26,7 @@ func WithPath(path string) OptsFunc {
} }
} }
func Format(ctx context.Context, optsFuncs ...OptsFunc) error { func format(ctx context.Context, optsFuncs ...OptsFunc) error {
opts := &Opts{ opts := &Opts{
Path: ".", Path: ".",
IgnoredFiles: []string{ IgnoredFiles: []string{
@ -74,3 +74,7 @@ func Format(ctx context.Context, optsFuncs ...OptsFunc) error {
return nil return nil
} }
func Format(ctx context.Context) error {
return format(ctx)
}

View File

@ -14,7 +14,7 @@ func TestCompile(t *testing.T) {
t.Run("With testdata", func(t *testing.T) { t.Run("With testdata", func(t *testing.T) {
ctx := context.Background() ctx := context.Background()
err := Format(ctx, WithPath("testdata/test_module")) err := format(ctx, withPath("testdata/test_module"))
assert.NoError(t, err) assert.NoError(t, err)
file, err := os.ReadFile("testdata/test_module/very_long_line.go") file, err := os.ReadFile("testdata/test_module/very_long_line.go")