Close leaking files in conformance/walk.go

We want to ensure we close this file handler if it was opened
successfully.
This commit is contained in:
mattjmcnaughton 2019-08-21 08:59:35 -04:00
parent d6035f3e0d
commit f7128535bd
No known key found for this signature in database
GPG Key ID: BC530981A9A1CC9D

View File

@ -180,6 +180,7 @@ func (v *visitor) comment(x *ast.BasicLit) string {
//proximity of the comment and apply it.
myf, err := os.Open(v.FileSet.File(x.Pos()).Name())
if err == nil {
defer myf.Close()
if _, err := myf.Seek(int64(comm.End()), 0); err == nil {
if _, err := myf.Read(b1); err == nil {
if strings.Compare(strings.Trim(string(b1), "\t \r\n"), "framework.ConformanceIt(\"") == 0 {