'yaml marshal kubernetes ResourceRequirements

I'm trying to marshal resources from a kubernetes CRDs I made, in this exercise I created my struct then I want to marshal it but with yaml.Marshal(my_struct) I get something like that:

limits:
  cpu:
    format: DecimalSI
  memory:
    format: BinarySI
requests:
  cpu:
    format: DecimalSI
  memory:
    format: BinarySI

The type I'm trying to marshal is https://pkg.go.dev/k8s.io/[email protected]/core/v1?utm_source=gopls#ResourceList I want to get the values cpu: "250m" and not the cpu.format: DecimalSI

thanks


EDIT: It seems that the resourcesList doesn't have everything it should for yaml marshal (it works for json) I was using the wrong package gopkg.in/yaml.v3 instead of this one sigs.k8s.io/yaml which is a "A wrapper around go-yaml designed to enable a better way of handling YAML when marshaling to and from structs."



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source