Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

MarshalYAML interface with and without pointers #714

@vanbroup

Description

@vanbroup

MarshalYAML doesn't seem to have the same behaviour as MarshalJSON, for example when the interface is implemented on an interface:

In encoding/json the MarshalJSON interface implemented as (d *Data) MarshalJSON() triggers on pointers and non-pointers:
https://play.golang.org/p/LFoqw1VHz8l

Doing the same with (d *Data) MarshalYAML(), doesn't work:
https://play.golang.org/p/hFnuiLpKq73

But when removing the pointer to (d Data) MarshalYAML() or by changing the data to pointers, it works fine:
https://play.golang.org/p/FyngGj0lATf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions