@@ -72,23 +72,26 @@ func main() {
7272
7373 for _ , dep := range externalDeps .Dependencies {
7474 for _ , refPath := range dep .RefPaths {
75- file , err := os .Open (refPath .Path )
76- if err != nil {
77- log .Fatalf ("error opening file %v : %v" , refPath .Path , err )
78- }
79- matcher := regexp .MustCompile (refPath .Match )
80- depFileScanner := bufio .NewScanner (file )
81- var found bool
82- for depFileScanner .Scan () {
83- line := depFileScanner .Text ()
84- if matcher .MatchString (line ) && strings .Contains (line , dep .Version ) {
85- found = true
86- break
75+ func () {
76+ file , err := os .Open (refPath .Path )
77+ if err != nil {
78+ log .Fatalf ("error opening file %v : %v" , refPath .Path , err )
8779 }
88- }
89- if ! found {
90- pathsToUpdate = append (pathsToUpdate , refPath .Path )
91- }
80+ defer file .Close ()
81+ matcher := regexp .MustCompile (refPath .Match )
82+ depFileScanner := bufio .NewScanner (file )
83+ var found bool
84+ for depFileScanner .Scan () {
85+ line := depFileScanner .Text ()
86+ if matcher .MatchString (line ) && strings .Contains (line , dep .Version ) {
87+ found = true
88+ break
89+ }
90+ }
91+ if ! found {
92+ pathsToUpdate = append (pathsToUpdate , refPath .Path )
93+ }
94+ }()
9295 }
9396 if len (pathsToUpdate ) > 0 {
9497 log .Fatalf (mismatchErrorMessage , externalDepsFilePath , dep .Name , dep .Version , strings .Join (pathsToUpdate , "\n " ), dep .Name , externalDepsFilePath )
0 commit comments