buuuut, to serialise a structure with encoding/json or encoding/xml (and anything else which uses reflect) the fields have to be public (start with a capital letter) anyway, so that breaks the deadlock with keywords of the same name.
On Wednesday, 5 October 2016 02:54:32 UTC+11, David Luu wrote: > > >> Why do you care? > > I personally wouldn't but a (test framework) protocol built on top of > XML-RPC that I want to interface to expects the following response back: > > <methodResponse> > <params> > <param> > <value><struct> > <member><name>return</name> > <value><int>42</int></value> > </member> > <member><name>status</name> > <value><string>PASS</string></value> > </member> > <member><name>output</name> > <value><string></string></value> > </member> > <member><name>error</name> > <value><string></string></value> > </member> > <member><name>traceback</name> > <value><string></string></value> > </member> > </struct></value> > </param> > </params> > </methodResponse> > > and the only XML-RPC (server) package for go I've found: > https://github.com/divan/gorilla-xmlrpc, guess what it uses to map that > kind of XML-RPC data structure to? A go struct. That was looking over the > README, haven't delved into the code for that package, but there might not > be other alternative options w/o modifying that package's code. A go map > might have been more flexible to workaround naming issues. > > Btw, I ran into this issue in .NET/C# too where an XML-RPC struct maps to > C# struct, and there was same keyword conflict. Thankfully though, the > XML-RPC.NET library had a workaround to remap/translate the naming for > the user/consumer: http://xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html#1.11. I > don't think such exists in the go XML-RPC package. :( > > >> [1] Capitialising the first letter will export the field name. You > might not have wanted to do that. > > good point, I forgot about that for a moment, being new to go. > > On Tuesday, October 4, 2016 at 5:30:18 AM UTC-7, David Luu wrote: >> >> Say I wanted to define a struct like this: >> >> type runKeywordReturnType struct{ >> return interface{} >> status string >> output string >> error string >> traceback string >> } >> >> Seems to not work since return and error are go keywords. If I capitalize >> the first letter, that works. But say I really wanted to keep it all >> lowercase, is there a way to do so in go? >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.