Skip to content

Replace to gopkg.in/yaml with github.com/goccy/go-yaml (slightly breaking change) #8822

Open
@bep

Description

@bep

Add this to have something to track this with.

The main blocker I see for this is that it's not possible to control location/timezone for dates without that information.

package main

import (
	"fmt"
	"log"

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

var data = `
d: 2021-07-15

`

func main() {
	mv2 := make(map[string]interface{})
	err := v2.Unmarshal([]byte(data), &mv2)
	if err != nil {
		log.Fatalf("error: %v", err)
	}
	fmt.Printf("--- mv2: %T %v \n", mv2["d"], mv2["d"])

	mv3 := make(map[string]interface{})
	err = v3.Unmarshal([]byte(data), &mv3)
	if err != nil {
		log.Fatalf("error: %v", err)
	}
	fmt.Printf("--- mv3: %T %v \n", mv3["d"], mv3["d"])
}

Prints:

--- mv2: string 2021-07-15 
--- mv3: time.Time 2021-07-15 00:00:00 +0000 UTC 

Note that v2 isn't perfect, either, but that at least allows us to handle known dates (e.g. the front matter dates).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions