Skip to content

Commit 8123d03

Browse files
committed
Undo the breaking changes to New()
1 parent e451dd2 commit 8123d03

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

boilingcore/boilingcore.go

+3-12
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,10 @@ import (
1515
"github.com/friendsofgo/errors"
1616
"github.com/volatiletech/sqlboiler/v4/drivers"
1717
"github.com/volatiletech/sqlboiler/v4/importers"
18+
boiltemplates "github.com/volatiletech/sqlboiler/v4/templates"
1819
"github.com/volatiletech/strmangle"
1920
)
2021

21-
const (
22-
templatesDirectory = "templates"
23-
templatesSingletonDirectory = "templates/singleton"
24-
25-
templatesTestDirectory = "templates_test"
26-
templatesSingletonTestDirectory = "templates_test/singleton"
27-
28-
templatesTestMainDirectory = "templates_test/main_test"
29-
)
30-
3122
var (
3223
// Tags must be in a format like: json, xml, etc.
3324
rgxValidTag = regexp.MustCompile(`[a-zA-Z_\.]+`)
@@ -49,7 +40,7 @@ type State struct {
4940
}
5041

5142
// New creates a new state based off of the config
52-
func New(config *Config, templatesBuiltin fs.FS) (*State, error) {
43+
func New(config *Config) (*State, error) {
5344
s := &State{
5445
Config: config,
5546
}
@@ -108,7 +99,7 @@ func New(config *Config, templatesBuiltin fs.FS) (*State, error) {
10899
return nil, err
109100
}
110101

111-
templates, err = s.initTemplates(templatesBuiltin)
102+
templates, err = s.initTemplates(boiltemplates.Builtin)
112103
if err != nil {
113104
return nil, errors.Wrap(err, "unable to initialize templates")
114105
}

boilingcore/boilingcore_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ func testNew(t *testing.T, aliases Aliases) {
9090
Aliases: aliases,
9191
}
9292

93-
templatesBuiltin := os.DirFS("../templates")
94-
if err != nil {
95-
t.Fatal(err)
96-
}
97-
state, err = New(config, templatesBuiltin)
93+
state, err = New(config)
9894
if err != nil {
9995
t.Fatalf("Unable to create State using config: %s", err)
10096
}

main.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package main
33

44
import (
5-
"embed"
65
"fmt"
76
"os"
87
"os/exec"
@@ -17,9 +16,6 @@ import (
1716
"github.com/volatiletech/sqlboiler/v4/importers"
1817
)
1918

20-
//go:embed templates templates_test
21-
var templatesBuiltin embed.FS
22-
2319
const sqlBoilerVersion = "4.7.0"
2420

2521
var (
@@ -220,7 +216,7 @@ func preRun(cmd *cobra.Command, args []string) error {
220216

221217
cmdConfig.Imports = configureImports()
222218

223-
cmdState, err = boilingcore.New(cmdConfig, templatesBuiltin)
219+
cmdState, err = boilingcore.New(cmdConfig)
224220
return err
225221
}
226222

0 commit comments

Comments
 (0)