Skip to content

Commit

Permalink
hepmc/go-hepmc-dump: use errors.Is to properly detect io.EOF
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien Binet <[email protected]>
  • Loading branch information
sbinet committed Jan 24, 2023
1 parent 5e5fc63 commit 5b6e048
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hepmc/go-hepmc-dump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
package main

import (
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -72,12 +73,13 @@ func main() {
}

func dump(w io.Writer, r io.Reader) error {
var err error
dec := hepmc.NewDecoder(r)
for {
var evt hepmc.Event
err = dec.Decode(&evt)
if err == io.EOF {
var (
evt hepmc.Event
err = dec.Decode(&evt)
)
if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
Expand Down

0 comments on commit 5b6e048

Please sign in to comment.