소스 검색

# fix : file close 没有关闭

Farmerx 7 년 전
부모
커밋
ce5b37a4ac
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      picture.go

+ 5 - 1
picture.go

@@ -88,7 +88,11 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error {
 	if !ok {
 		return errors.New("Unsupported image extension")
 	}
-	readFile, _ := os.Open(picture)
+	readFile, err := os.Open(picture)
+	if err!=nil{
+		return err
+	}
+	defer readFile.Close()
 	image, _, _ := image.DecodeConfig(readFile)
 	_, file := filepath.Split(picture)
 	formatSet, err := parseFormatPictureSet(format)