Skip to content

Commit 4f1c3d0

Browse files
feat: add file parameter to UnmarshalWithOrigin
Pass source file path to yaml3 decoder so origin locations include the file they were parsed from. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f31be36 commit 4f1c3d0

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/oasdiff/yaml
22

33
go 1.22.5
44

5-
require github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90
5+
require github.com/oasdiff/yaml3 v0.0.0-20260217201013-8a620da6102a

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
2-
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
1+
github.com/oasdiff/yaml3 v0.0.0-20260217201013-8a620da6102a h1:so9gdCU1AyG+EFCCp6ORLut4MBi/wIh4J3jGrEjNZnI=
2+
github.com/oasdiff/yaml3 v0.0.0-20260217201013-8a620da6102a/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
33
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
44
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

yaml.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"reflect"
1717
"strconv"
1818

19-
"github.com/oasdiff/yaml3"
19+
yaml "github.com/oasdiff/yaml3"
2020
)
2121

2222
// Marshal the object into JSON then converts JSON to YAML and returns the
@@ -44,14 +44,14 @@ type YAMLOpt func(*yaml.Decoder) *yaml.Decoder
4444
// Unmarshal converts YAML to JSON then uses JSON to unmarshal into an object,
4545
// optionally configuring the behavior of the JSON unmarshal.
4646
func Unmarshal(y []byte, o interface{}, opts ...JSONOpt) error {
47-
return UnmarshalWithOrigin(y, o, false, opts...)
47+
return UnmarshalWithOrigin(y, o, false, "", opts...)
4848
}
4949

5050
// UnmarshalWithOrigin is like Unmarshal but if withOrigin is true, it will
5151
// include the origin information in the output.
52-
func UnmarshalWithOrigin(y []byte, o interface{}, withOrigin bool, opts ...JSONOpt) error {
52+
func UnmarshalWithOrigin(y []byte, o interface{}, withOrigin bool, file string, opts ...JSONOpt) error {
5353
dec := yaml.NewDecoder(bytes.NewReader(y))
54-
dec.Origin(withOrigin)
54+
dec.Origin(withOrigin, file)
5555
return unmarshal(dec, o, opts)
5656
}
5757

0 commit comments

Comments
 (0)