Skip to content

Commit 4228cbc

Browse files
Fix silent error swallowing in cmd/main.go
Handle the error returned by os.ReadFile() in insert_purls instead of discarding it with _. Previously, if a data file could not be read, zero PURLs were silently inserted into the FST with no indication of failure. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent bc44a00 commit 4228cbc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ func main() {
5555
}
5656

5757
func insert_purls(builder *vellum.Builder, file string) int {
58-
var err error
5958
// #nosec G304
60-
data, _ := os.ReadFile(file)
59+
data, err := os.ReadFile(file)
60+
if err != nil {
61+
log.Fatal(err)
62+
}
6163
lines := strings.FieldsFunc(string(data), func(r rune) bool {
6264
return r == '\n'
6365
})

0 commit comments

Comments
 (0)