Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
9eade33
Fix for non-specific tags parsing
a-chernykh May 25, 2015
e90bcf7
add examples for decoding embedded structs
mvo5 Apr 7, 2015
31c2992
new license in the README file (#189)
chillum Sep 12, 2016
a5b47d3
Fix unmarshaler handling of empty strings.
niemeyer Sep 28, 2016
14227de
Fix decode test for Go 1.8 (#217)
dsnet Jan 24, 2017
4c78c97
Tighten restrictions on float decoding (#171)
Jan 25, 2017
a3f3340
Fix dead URL for yaml specification (#240)
xulike666 Feb 8, 2017
cd8b52f
Remove unreachable code to fix go vet (#249)
mogthesprog Apr 7, 2017
f2d2788
docs: note need for public struct fields
heldtogether Apr 27, 2017
a311394
encoder.marshal panics on nil pointers
May 6, 2017
f59f5e6
fix misspell on emmiterc.go
hiveminded Jun 26, 2017
e72f935
correct misspell on yamlh.go
hiveminded Jun 26, 2017
f8db564
Add UnmarshalStrict returning error if yaml has fields that do not ex…
wupeka Jun 13, 2017
1be3d31
Merge pull request #262 from wupeka/v2
rogpeppe Jul 12, 2017
3b4ad1d
Merge pull request #264 from hiveminded/v2
rogpeppe Jul 13, 2017
835086a
Merge pull request #94 from mvo5/feature/embeded-structs-example
rogpeppe Jul 21, 2017
d56ec34
move embedded struct example into godoc
rogpeppe Jul 21, 2017
7ddc463
Merge pull request #271 from rogpeppe/004-embedded-example
rogpeppe Jul 21, 2017
670d4cf
Merge pull request #103 from andreychernih/bugfix/non-specific-tags
rogpeppe Jul 21, 2017
e9bfed5
Make tag scanning code slightly cleaner.
rogpeppe Jul 21, 2017
25c4ec8
Merge pull request #272 from rogpeppe/005-cleaner-tag-scan
rogpeppe Jul 21, 2017
c75e52e
Add support for alternative timestamp formats
Aug 11, 2015
422f540
Fixes to timestamp support.
rogpeppe Jul 21, 2017
eb3733d
Replace LICENSE text with actual license (#274)
king-jam Aug 12, 2017
283fbcd
Print the correct line number of YAML file if an unexpected field is …
Sep 8, 2017
08434a8
Support usage of "~" to indicate null values
rliebz Nov 12, 2017
2c9db35
Merge pull request #289 from rliebz/null-fix
rogpeppe Nov 16, 2017
287cf08
Correct documentation for Marshal (#287)
gbbr Nov 16, 2017
7cdd87a
Create NOTICE
king-jam Dec 12, 2017
c95af92
Merge pull request #281 from houshengbo/fix-incorrect-line-number
rogpeppe Jan 2, 2018
d6b5338
gofmt
rogpeppe Jan 4, 2018
0e4404d
Merge pull request #299 from rogpeppe/009-gofmt
rogpeppe Jan 4, 2018
add015b
do not allow forward references
rogpeppe Jan 4, 2018
73a1567
Merge pull request #300 from rogpeppe/008-no-forward-ref
rogpeppe Jan 5, 2018
8e626de
add Decoder type
rogpeppe Jan 5, 2018
0ee3698
Merge pull request #301 from rogpeppe/011-decoder
rogpeppe Jan 5, 2018
18e5f12
do not read ahead unnecessarily
rogpeppe Jan 5, 2018
fe9486c
allow plain scalars with colons inside flow mappings and sequences
rogpeppe Jan 4, 2018
39e59aa
Merge pull request #304 from rogpeppe/013-read-on-demand
rogpeppe Jan 5, 2018
9e27074
Merge pull request #305 from rogpeppe/010-issue-295
rogpeppe Jan 5, 2018
c4a9fb4
Merge pull request #273 from rogpeppe/006-timestamps
rogpeppe Jan 7, 2018
e4ac4c4
implement Encoder
rogpeppe Jan 5, 2018
5edc3de
Enforce key uniqueness in strict mode
rogpeppe Jan 7, 2018
77b384e
Merge pull request #307 from rogpeppe/015-strict-duplicates
rogpeppe Jan 8, 2018
4341420
revert #273
rogpeppe Jan 8, 2018
1244d3c
Merge pull request #308 from rogpeppe/016-revert-v2-PR273
rogpeppe Jan 8, 2018
0a6d1b0
Merge pull request #292 from king-jam/patch-1
rogpeppe Jan 8, 2018
7b07923
Merge pull request #306 from rogpeppe/014-encoder
rogpeppe Jan 8, 2018
a72a87d
Add support for alternative timestamp formats
Aug 11, 2015
1f2a25b
Fixes to timestamp support.
rogpeppe Jul 21, 2017
87e4a22
Merge pull request #310 from rogpeppe/018-timestamps
rogpeppe Jan 8, 2018
3c68098
Merge pull request #256 from sb-akd/v2
rogpeppe Jan 8, 2018
ab5d55c
add test for nil TestMarshaler
rogpeppe Jan 8, 2018
cdd36ee
Merge pull request #311 from rogpeppe/019-nil-marshaler-test
rogpeppe Jan 8, 2018
b7fbda9
use 64 bit precision when formatting float values
rogpeppe Jan 9, 2018
031c922
Merge pull request #314 from rogpeppe/021-64-bit-floats
rogpeppe Jan 9, 2018
60a2abf
omitempty use IsZero
rogpeppe Jan 9, 2018
1f1f618
Update README.md
rogpeppe Jan 9, 2018
d670f94
Merge pull request #253 from heldtogether/patch-1
rogpeppe Jan 9, 2018
8ed39f3
Merge pull request #315 from rogpeppe/022-iszero
rogpeppe Jan 12, 2018
3eb2270
Merge remote-tracking branch 'origin/devel' into HEAD
rogpeppe Feb 23, 2018
3e6d767
Merge pull request #335 from rogpeppe/024-merge-devel
rogpeppe Feb 23, 2018
49fdd64
add go.mod file
rogpeppe Feb 23, 2018
7f97868
Merge pull request #336 from rogpeppe/025-go.mod
rogpeppe Feb 23, 2018
dcd83b3
Fix unstable map key ordering (#195).
niemeyer Mar 25, 2018
200c098
Improve map stabilization logic.
niemeyer Mar 25, 2018
0409226
Drop invalid simple key assertion.
niemeyer Mar 26, 2018
3ba0e99
Ensure scanner has data before checking for blanks.
niemeyer Mar 26, 2018
1b2e8c1
Fix curious assumption from the original C reader.
niemeyer Mar 26, 2018
62e345d
Remove mention of non-existent examples folder.
niemeyer Mar 26, 2018
7b8fd2d
Fix edge case when decoding MinInt as -0b.
niemeyer Mar 26, 2018
2aba0a4
Encode and decode arrays.
niemeyer Mar 26, 2018
9a4310b
Convert int to float when explicitly tagged.
niemeyer Mar 26, 2018
e47eca5
increment non-zero scanner error lines (#319)
vitreuz Mar 26, 2018
119a11e
Fix broken test from last merge.
niemeyer Mar 26, 2018
86f5ed6
Drop unnecessary explicit timestamp tags.
niemeyer Mar 26, 2018
7c97801
Fixed typos in docstrings (#179).
joe2far Mar 26, 2018
f7e2331
Fix type on Marshal docs (#206).
hartzell Mar 26, 2018
14d1c46
Fix misspell of precede in ported code (#216)
Mar 26, 2018
4fc5987
Fix typo in tab error message (#208).
mmb Mar 26, 2018
5420a8b
Use underlying float precision when formatting floats (#353)
prashantv Mar 28, 2018
51d6538
Add support for json.Number. (#414)
echlebek Nov 15, 2018
7b8349a
Parse floats correctly and fix mistake from #171
niemeyer Mar 19, 2019
bb4e33b
Add logic to catch cases of alias abuse.
niemeyer Jul 8, 2019
f221b84
Improve heuristics preventing CPU/memory abuse (#515)
liggitt Oct 2, 2019
970885f
Trivial style tuning on last change.
niemeyer Oct 2, 2019
f90ceb4
Fix check for non-map alias merging in v2 (#529)
niemeyer Nov 4, 2019
1ed5951
Add Go 1.10-13 to travis setup.
niemeyer Nov 5, 2019
770b8da
Fix Decorder doc typo (#494)
cunnie Nov 5, 2019
36babc3
Port stale simple_keys fix to v2 (#543)
cjcullen Nov 19, 2019
a95acef
Update travis config to use latest go versions (#540)
chenrui333 Nov 19, 2019
1f64d61
Fix issue in simple_keys improvements (#548)
niemeyer Nov 19, 2019
53403b5
Optimize cases with long potential simple_keys (#555)
cjcullen Jan 21, 2020
0b1645d
Set the default line length to infinity (-1) (#571)
laverya May 6, 2020
bf81f7e
Fix Marshal documentation on omitempty and IsZero (#608)
afriza Jun 2, 2020
b893565
Add go1.14 into travis config (#585)
chenrui333 Jun 2, 2020
7649d45
Revert v2 line length change as discussed in #670
niemeyer Nov 17, 2020
3a17399
[v2] Switch to official vanity package name
dims May 18, 2025
246a95c
[v2] Fix the URL in the package documentation
carloslima Jun 2, 2025
817719a
Fix parsing of non-specific node tags (issue #75)
Oct 13, 2015
9d04d59
Call UnmarshalYAML on literal empty string values
Nov 25, 2014
d199d5e
no need for Fix parsing of non-specific node tags (issue #75)
emosbaugh Sep 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
language: go

go:
- 1.4
- 1.5
- 1.6
- tip
- "1.4.x"
- "1.5.x"
- "1.6.x"
- "1.7.x"
- "1.8.x"
- "1.9.x"
- "1.10.x"
- "1.11.x"
- "1.12.x"
- "1.13.x"
- "1.14.x"
- "tip"

go_import_path: gopkg.in/yaml.v2
208 changes: 198 additions & 10 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,13 +1,201 @@
Copyright 2011-2016 Canonical Ltd.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

http://www.apache.org/licenses/LICENSE-2.0
1. Definitions.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
13 changes: 13 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2011-2016 Canonical Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ supported since they're a poor design and are gone in YAML 1.2.
Installation and usage
----------------------

The import path for the package is *gopkg.in/yaml.v2*.
The import path for the package is *go.yaml.in/yaml/v2*.

To install it, run:

go get gopkg.in/yaml.v2
go get go.yaml.in/yaml/v2

API documentation
-----------------

If opened in a browser, the import path itself leads to the API documentation:

* [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2)
See: <https://pkg.go.dev/go.yaml.in/yaml/v2>

API stability
-------------
Expand All @@ -42,7 +40,7 @@ The package API for yaml v2 will remain stable as described in [gopkg.in](https:
License
-------

The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details.
The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details.


Example
Expand All @@ -55,7 +53,7 @@ import (
"fmt"
"log"

"gopkg.in/yaml.v2"
"go.yaml.in/yaml/v2"
)

var data = `
Expand All @@ -65,6 +63,8 @@ b:
d: [3, 4]
`

// Note: struct fields must be public in order for unmarshal to
// correctly populate the data.
type T struct {
A string
B struct {
Expand Down
Loading