Skip to content

Panic reflect.Set: value of type string is not assignable to type Foo #741

@leungster

Description

@leungster

Describe the bug
I have a type declaration type Foo string and trying to unmarshal a yaml int value into it.
When the decoder tries to set the value it panics.

panic: reflect.Set: value of type string is not assignable to type Foo

It works fine if the value is a string and not the type def of Foo.

To Reproduce

https://go.dev/play/p/hC1y4099nrf

Expected behavior
Unmarshaling should work the same for string and type xxx string

Version Variables

  • Go version: 1.24.3
  • go-yaml's Version: 1.17.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions