struct fields are not indirected correctly for SetYAML

Bug #1225038 reported by Roger Peppe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
goyaml
New
Undecided
Unassigned

Bug Description

The following program illustrates the problem. The encoding/json package does the right thing here.
I would expect to see the "set yaml called correctly" panic.

package main
import (
 "fmt"
 "launchpad.net/goyaml"
 "encoding/json"
)

type Foo struct {
 S Bar
}

type Bar int

func (b *Bar) SetYAML(tag string, value interface{}) bool {
 panic("set yaml called correctly")
}

func (b *Bar) UnmarshalJSON([]byte) error {
 panic("unmarshal json called correctly")
}

func main() {
 var foo Foo
 err := goyaml.Unmarshal([]byte("S: 345"), &foo)
 fmt.Printf("yaml err: %v\n", err)

 err = json.Unmarshal([]byte(`{"S": 345}`), &foo)
 fmt.Printf("json err: %v\n", err)
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.