| 1 |
# goyaml.v2 |
| 2 |
|
| 3 |
This package provides type and function aliases for the `go.yaml.in/yaml/v2` package (which is compatible with `gopkg.in/yaml.v2`). |
| 4 |
|
| 5 |
## Purpose |
| 6 |
|
| 7 |
The purpose of this package is to: |
| 8 |
|
| 9 |
1. Provide a transition path for users migrating from the sigs.k8s.io/yaml package to direct usage of go.yaml.in/yaml/v2 |
| 10 |
2. Maintain compatibility with existing code while encouraging migration to the upstream package |
| 11 |
3. Reduce maintenance overhead by delegating to the upstream implementation |
| 12 |
|
| 13 |
## Usage |
| 14 |
|
| 15 |
Instead of importing this package directly, you should migrate to using `go.yaml.in/yaml/v2` directly: |
| 16 |
|
| 17 |
```go |
| 18 |
// Old way |
| 19 |
import "sigs.k8s.io/yaml/goyaml.v2" |
| 20 |
|
| 21 |
// Recommended way |
| 22 |
import "go.yaml.in/yaml/v2" |
| 23 |
``` |
| 24 |
|
| 25 |
## Available Types and Functions |
| 26 |
|
| 27 |
All public types and functions from `go.yaml.in/yaml/v2` are available through this package: |
| 28 |
|
| 29 |
### Types |
| 30 |
|
| 31 |
- `MapSlice` - Encodes and decodes as a YAML map with preserved key order |
| 32 |
- `MapItem` - An item in a MapSlice |
| 33 |
- `Unmarshaler` - Interface for custom unmarshaling behavior |
| 34 |
- `Marshaler` - Interface for custom marshaling behavior |
| 35 |
- `IsZeroer` - Interface to check if an object is zero |
| 36 |
- `Decoder` - Reads and decodes YAML values from an input stream |
| 37 |
- `Encoder` - Writes YAML values to an output stream |
| 38 |
- `TypeError` - Error returned by Unmarshal for decoding issues |
| 39 |
|
| 40 |
### Functions |
| 41 |
|
| 42 |
- `Unmarshal` - Decodes YAML data into a Go value |
| 43 |
- `UnmarshalStrict` - Like Unmarshal but errors on unknown fields |
| 44 |
- `Marshal` - Serializes a Go value into YAML |
| 45 |
- `NewDecoder` - Creates a new Decoder |
| 46 |
- `NewEncoder` - Creates a new Encoder |
| 47 |
- `FutureLineWrap` - Controls line wrapping behavior |
| 48 |
|
| 49 |
## Migration Guide |
| 50 |
|
| 51 |
To migrate from this package to `go.yaml.in/yaml/v2`: |
| 52 |
|
| 53 |
1. Update your import statements: |
| 54 |
```go |
| 55 |
// From |
| 56 |
import "sigs.k8s.io/yaml/goyaml.v2" |
| 57 |
|
| 58 |
// To |
| 59 |
import "go.yaml.in/yaml/v2" |
| 60 |
``` |
| 61 |
|
| 62 |
2. No code changes should be necessary as the API is identical |
| 63 |
|
| 64 |
3. Update your go.mod file to include the dependency: |
| 65 |
``` |
| 66 |
require go.yaml.in/yaml/v2 v2.4.2 |
| 67 |
``` |
| 68 |
|
| 69 |
## Deprecation Notice |
| 70 |
|
| 71 |
All types and functions in this package are marked as deprecated. You should migrate to using `go.yaml.in/yaml/v2` directly. |