From 3b9aff538d81a43f79c6a5fb9989a0181eefa70b Mon Sep 17 00:00:00 2001 From: d_infinite <463394797@qq.com> Date: Wed, 13 Apr 2022 18:04:40 +0800 Subject: [PATCH] feat: support parse from reader --- gopom.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gopom.go b/gopom.go index 6136de1..5593d19 100644 --- a/gopom.go +++ b/gopom.go @@ -24,6 +24,17 @@ func Parse(path string) (*Project, error) { return &project, nil } +func ParseFromReader(reader io.Reader) (*Project, error) { + b, _ := ioutil.ReadAll(reader) + var project Project + + err := xml.Unmarshal(b, &project) + if err != nil { + return nil, err + } + return &project, nil +} + type Project struct { XMLName xml.Name `xml:"project"` ModelVersion string `xml:"modelVersion"`