@@ -6,9 +6,11 @@ import (
66 "encoding/json"
77 "fmt"
88 "io/fs"
9+ "maps"
910 "os"
1011 "path/filepath"
1112 "regexp"
13+ "slices"
1214 "sort"
1315 "strings"
1416
@@ -74,9 +76,7 @@ func New(config *Config) (*State, error) {
7476 }()
7577
7678 if len (s .Config .Version ) > 0 {
77- noEditDisclaimer = []byte (
78- fmt .Sprintf (noEditDisclaimerFmt , " " + s .Config .Version + " " ),
79- )
79+ noEditDisclaimer = fmt .Appendf (nil , noEditDisclaimerFmt , " " + s .Config .Version + " " )
8080 }
8181
8282 if err := s .verifyModVersion (); err != nil {
@@ -258,7 +258,7 @@ func (s *State) initTemplates() ([]lazyTemplate, error) {
258258 return nil , err
259259 }
260260
261- mergeTemplates (templates , tpls )
261+ maps . Copy (templates , tpls )
262262 }
263263 } else {
264264 defaultTemplates := s .Config .DefaultTemplates
@@ -594,13 +594,7 @@ func shouldReplaceInTable(t drivers.Table, r TypeReplace) bool {
594594 return true
595595 }
596596
597- for _ , replaceInTable := range r .Tables {
598- if replaceInTable == t .Name {
599- return true
600- }
601- }
602-
603- return false
597+ return slices .Contains (r .Tables , t .Name )
604598}
605599
606600// initOutFolders creates the folders that will hold the generated output.
@@ -701,12 +695,6 @@ func checkPKeys(tables []drivers.Table) error {
701695 return nil
702696}
703697
704- func mergeTemplates (dst , src map [string ]templateLoader ) {
705- for k , v := range src {
706- dst [k ] = v
707- }
708- }
709-
710698// normalizeSlashes takes a path that was made on linux or windows and converts it
711699// to a native path.
712700func normalizeSlashes (path string ) string {
@@ -744,12 +732,12 @@ func (s *State) verifyModVersion() error {
744732
745733 gomodbytes , err := os .ReadFile (path )
746734 if err != nil {
747- return fmt .Errorf (fmt . Sprintf ( "could not read go.mod: %v " , err ) )
735+ return fmt .Errorf ("could not read go.mod: %w " , err )
748736 }
749737
750738 re , err := regexp .Compile (`github\.com\/aarondl\/sqlboiler\/v4 v(\d*\.\d*\.\d*)` )
751739 if err != nil {
752- return fmt .Errorf ("failed to parse regexp: %v " , err )
740+ return fmt .Errorf ("failed to parse regexp: %w " , err )
753741 }
754742
755743 match := re .FindSubmatch (gomodbytes )
0 commit comments