goccy / go-yaml

YAML support for the Go language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unwanted int to float conversion

xsilas opened this issue · comments

Describe the bug
Using the Marshal function on a interface{} converts an integer to a float value despite the gopkg yamlv3 (gopkg.in/yaml.v3) does not:
Port somehow turns into a float:

  • docker:
    file: Dockerfile
    platform:
    • arch: amd64
      os: linux
    • arch: arm64
      os: linux
      ingresses:
    • host: www
      name: website
      ports:
    • 8080.0
      resources: {}
      user: "101"

To Reproduce

yamlv3Bytes, err := yamlv3.Marshal(someInterface)
if err != nil {
return err
}
fmt.Println(string(yamlv3Bytes))

yamlBytes, err := yaml.Marshal(someInterface)
if err != nil {
return err
}
fmt.Println(string(yamlBytes))

Expected behavior
Port should remain an int like so:

  • docker:
    file: Dockerfile
    platform:
    - arch: amd64
    os: linux
    - arch: arm64
    os: linux
    ingresses:
    • host: www
      name: website
      ports:
    • 8080
      resources: {}
      user: "101"

Screenshots
Bildschirmfoto vom 2024-02-19 11-32-17

Version Variables

  • Go version: 1.22
  • go-yaml's Version: v1.11.3

Additional context
If theres a mistake / missunderstanding on my side please let me know