You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
go play environment
What did you do?
import (
"encoding/json"
"fmt"
)
type Bar interface {
IsBar()
}
type Barred struct {
Str string
}
func (Barred) IsBar() {
}
type Foo1 struct {
Bar
I int
}
type Foo2 struct {
Barred
I int
}
func main() {
var b Barred = Barred{Str: "abc"}
var f1 Foo1 = Foo1{Bar: b, I: 123}
var f2 Foo2 = Foo2{Barred: b, I: 123}
e1, _ := json.Marshal(f1)
e2, _ := json.Marshal(f2)
if string(e1) != string(e2) {
fmt.Println("Interface and Structure marshalled differently")
}
}
What did you expect to see?
strings e1 and e2 to be equivalent
What did you see instead?
string e1 contained an nested structure labelled Bar instead of embedding the values into the base struct Foo1
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?1.19
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go play environment
What did you do?
What did you expect to see?
strings e1 and e2 to be equivalent
What did you see instead?
string e1 contained an nested structure labelled
Bar
instead of embedding the values into the base struct Foo1The text was updated successfully, but these errors were encountered: