<pre class="notranslate">the 386 builders are all dying in the go.net subrepo with messages like

?       code.google.com/p/go.net/dict   [no test files]
ok      code.google.com/p/go.net/html   0.140s
ok      code.google.com/p/go.net/html/atom  0.006s
# code.google.com/p/go.net/ipv4
registers allocated at
    AX  0
    CX  0
    DX  0
    BX  0xd2f8
    SP  0
    BP  0xd2f8
    SI  0xd2f8
    DI  0xc1b7
registers allocated at
    AX  0
    CX  0
    DX  0
    BX  0xd2f8
    SP  0
    BP  0xd2f8
    SI  0xd2f8
    DI  0xc1b7
/tmp/gobuilder/darwin-386-03e5b26282f7/src/code.google.com/p/go.net/ipv4/control.go:1:
out of fixed registers
/tmp/gobuilder/darwin-386-03e5b26282f7/src/code.google.com/p/go.net/ipv4/control.go:1:
internal compiler error: regfree: reg not allocated
ok      code.google.com/p/go.net/html/charset   0.011s
ok      code.google.com/p/go.net/idna   0.013s
FAIL    code.google.com/p/go.net/ipv4 [build failed]
# code.google.com/p/go.net/ipv6
registers allocated at
    AX  0
    CX  0
    DX  0
    BX  0xd2f8
    SP  0
    BP  0xd2f8
    SI  0xd2f8
    DI  0xc1b7
registers allocated at
    AX  0
    CX  0
    DX  0
    BX  0xd2f8
    SP  0
    BP  0xd2f8
    SI  0xd2f8
    DI  0xc1b7
/tmp/gobuilder/darwin-386-03e5b26282f7/src/code.google.com/p/go.net/ipv6/control.go:1:
out of fixed registers
/tmp/gobuilder/darwin-386-03e5b26282f7/src/code.google.com/p/go.net/ipv6/control.go:1:
internal compiler error: regfree: reg not allocated
FAIL    code.google.com/p/go.net/ipv6 [build failed]
ok      code.google.com/p/go.net/netutil    0.642s
ok      code.google.com/p/go.net/proxy  0.010s
ok      code.google.com/p/go.net/publicsuffix   0.178s
ok      code.google.com/p/go.net/spdy   0.017s
ok      code.google.com/p/go.net/websocket  0.030s</pre>
<p dir="auto">Currently if there are duplicate anonymous struct fields they are all ignored. I think this is wrong because the encoding process shouldn't loose information unless the output format is not capable to represent it(which is not the case).<br>
For example marshalling AllTypes produces an empty output.<br>
type AllTypes struct {<br>
Type1<br>
Type2<br>
}<br>
type Type1 struct {<br>
Name    string<br>
Address string<br>
}<br>
type Type2 struct {<br>
Name    string<br>
Address string<br>
}<br>
To overcome this issue an additional step is required to create a boilerplate type specially for the encoding/decoding process. Most likely we end-up with a new type (AllTypes2) as below. This is against the composability of the language and adds additional burden to the developer(look for duplicate fields -&gt;  create a new type).</p>
<p dir="auto">type AllTypes2 struct{<br>
Type1 Type1<br>
Type2 Type2<br>
}</p>
<p dir="auto">Any fix/convention that preserves the data would be fine to me but I present my proposal below too as starting point. I think it's also backward compatible.<br>
<strong>Use the same addressing like the native go types</strong>.<br>
If there are duplicate anonymous fields, they should be addressed using the type name as prefix. If the type name is duplicate too both the package name and the type name should be used as prefix. For type AllTypes I would expect the output below:</p>
<p dir="auto">{<br>
"Type1": {"Name":"example", "Address": "example"},<br>
"Type2": {"Name":"example", "Address": "example"}<br>
}</p>
<p dir="auto">Using the same addressing as on go types makes the behaviour intuitive and easier to understand too as we have only one familiar rule instead of 3 special rules.<br>
It would make the behaviour more consistent too because the type name is already used as key on certain cases. For example type SomeType is encoded  to {"MySlice":["somedata"]}.<br>
type SomeType struct{<br>
MySlice<br>
}<br>
type MySlice []string</p>