Skip to content

Unwanted int to float conversion #427

@xsilas

Description

@xsilas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions