diff --git a/external_coachsequence.go b/external_coachsequence.go index d890f71b0bca870386bba677700d09b3b99b6e8a..67ae95dea2c147a7e74406986c77fbd3508c416a 100644 --- a/external_coachsequence.go +++ b/external_coachsequence.go @@ -2,15 +2,16 @@ package bahn import ( "encoding/json" + "io" "strconv" "strings" "time" "unicode" ) -func CoachSequenceFromDecoder(source json.Decoder) (CoachSequence, error) { +func CoachSequenceFromReader(source io.Reader) (CoachSequence, error) { var raw rawCoachSequence - if err := source.Decode(&raw); err != nil { + if err := json.NewDecoder(source).Decode(&raw); err != nil { return CoachSequence{}, err } return parseCoachSequence(raw), nil diff --git a/external_station.go b/external_station.go index e3d11cbb18ff7efd60a677762baef900aaed5f8b..955c895973916329a8f30b0ea7cfdfac88aa35e4 100644 --- a/external_station.go +++ b/external_station.go @@ -1,10 +1,13 @@ package bahn -import "encoding/xml" +import ( + "encoding/xml" + "io" +) -func StationsFromDecoder(source xml.Decoder) ([]Station, error) { +func StationsFromReader(source io.Reader) ([]Station, error) { var raw rawStations - if err := source.Decode(&raw); err != nil { + if err := xml.NewDecoder(source).Decode(&raw); err != nil { return make([]Station, 0), err } return parseStations(raw), nil diff --git a/external_timetable.go b/external_timetable.go index 6665990fbc864012c0a601e4db3b3fcb3fa03621..fb354ae70993569ea6223666a0c76b215144c806 100644 --- a/external_timetable.go +++ b/external_timetable.go @@ -3,11 +3,12 @@ package bahn import ( "encoding/xml" "fmt" + "io" ) -func TimetableFromDecoder(source xml.Decoder) (Timetable, error) { +func TimetableFromReader(source io.Reader) (Timetable, error) { var raw rawTimetable - if err := source.Decode(&raw); err != nil { + if err := xml.NewDecoder(source).Decode(&raw); err != nil { return Timetable{}, err } return parseTimetable(raw), nil diff --git a/external_wings.go b/external_wings.go index 32afccfefd6b6450608682f3d3a235f711896719..9575c0f612f979001fbfa9a164ea7c273d85b31d 100644 --- a/external_wings.go +++ b/external_wings.go @@ -1,10 +1,13 @@ package bahn -import "encoding/xml" +import ( + "encoding/xml" + "io" +) -func WingDefinitionFromDecoder(source xml.Decoder) (WingDefinition, error) { +func WingDefinitionFromReader(source io.Reader) (WingDefinition, error) { var raw rawWingDefinition - if err := source.Decode(&raw); err != nil { + if err := xml.NewDecoder(source).Decode(&raw); err != nil { return WingDefinition{}, err } return parseWingDefinition(raw), nil