Skip to content

Commit af81e63

Browse files
committed
fix: avoid shadowing of 'resource' and 'err' in machinery scaffold
Renamed the parameter 'resource' to 'res' in the WithResource function to avoid shadowing the imported package. Also replaced ':=' with '=' when assigning to 'err' to prevent redeclaration and shadowing of the existing error variable. These changes improve code clarity and follow Go best practices.
1 parent e3658a6 commit af81e63

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/machinery/scaffold.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ func WithBoilerplate(boilerplate string) ScaffoldOption {
110110
}
111111

112112
// WithResource provides the resource to the Scaffold
113-
func WithResource(resource *resource.Resource) ScaffoldOption {
113+
func WithResource(res *resource.Resource) ScaffoldOption {
114114
return func(s *Scaffold) {
115-
s.injector.resource = resource
115+
s.injector.resource = res
116116
}
117117
}
118118

@@ -492,7 +492,7 @@ func (s Scaffold) writeFile(f *File) (err error) {
492492
}
493493

494494
// Create the directory if needed
495-
if err := s.fs.MkdirAll(filepath.Dir(f.Path), s.dirPerm); err != nil {
495+
if err = s.fs.MkdirAll(filepath.Dir(f.Path), s.dirPerm); err != nil {
496496
return CreateDirectoryError{err}
497497
}
498498

0 commit comments

Comments
 (0)