@@ -72,23 +72,26 @@ func main() {
72
72
73
73
for _ , dep := range externalDeps .Dependencies {
74
74
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 )
87
79
}
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
+ }()
92
95
}
93
96
if len (pathsToUpdate ) > 0 {
94
97
log .Fatalf (mismatchErrorMessage , externalDepsFilePath , dep .Name , dep .Version , strings .Join (pathsToUpdate , "\n " ), dep .Name , externalDepsFilePath )
0 commit comments