Describe the bug
Encoding a struct with a field which is a type definition that implements TextMarshaller interface ends with a segmentation error.
To Reproduce
Playground link: https://go.dev/play/p/antYUlJajpY
package main
import (
"os"
"github.com/goccy/go-yaml"
)
type Foo struct {
Bar Bar `json:"bar"`
}
type Bar string
func (x Bar) MarshalText() ([]byte, error) {
return []byte(string(x)), nil
}
func main() {
x := Foo{}
enc := yaml.NewEncoder(os.Stdout)
if err := enc.Encode(x); err != nil {
panic(err)
}
}
Expected behavior
No error occurs :)
Version Variables
- Go version: 1.24.2
- go-yaml's Version: v1.17.1