Skip to content

Commit

Permalink
Use io, not ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti committed Jan 14, 2024
1 parent b9e66d1 commit 506ed81
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"mime"
"mime/multipart"
Expand Down Expand Up @@ -146,6 +146,9 @@ func getTable(file *extract.File) ([][]string, error) {
// }
output, err := textract.DetectDocumentText(file)
log.Printf("textract: %s", time.Since(startOCR).String())
if err != nil {
return nil, fmt.Errorf("textract text detection failed: %w", err)
}
startAlgorithm := time.Now()
table, err := textract.ToTableFromOCR(output)
log.Printf("ocr-to-table: %s", time.Since(startAlgorithm).String())
Expand Down Expand Up @@ -265,7 +268,7 @@ func getFile(decodedBodyBytes []byte, contentTypeHeader string) (*extract.File,
if err != nil {
return nil, fmt.Errorf("failed to fetch url '%s': %w", u, err)
}
bs, err := ioutil.ReadAll(resp.Body)
bs, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response from url fetch: %w", err)
}
Expand Down Expand Up @@ -340,7 +343,7 @@ func getFile(decodedBodyBytes []byte, contentTypeHeader string) (*extract.File,
if err != nil {
return nil, fmt.Errorf("failed to open file': %w", err)
}
data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return nil, fmt.Errorf("failed to read file': %w", err)
}
Expand Down

0 comments on commit 506ed81

Please sign in to comment.