Thanks for the help if REST XML output xs:double value supports scientific notation then it's fine I will keep it as is
Thanks, Abhi On Saturday, March 31, 2018 at 2:24:51 PM UTC+5:30, Jesper Louis Andersen wrote: > > The underlying question is: why do you want to use an 'f' representation > of a floating point value rather than a 'g' representation? > > If I read the XML Schema specification correctly, then an xs:double value > is allowed to be in scientific notation, so there should be little reason > to output this value in a different representation. A reader of said XML > document should be able to parse and handle that value with little trouble. > Think of the XML document as a transport format, where a client is going to > do its own internal representation. > > Generally speaking, it is often good to think twice before changing a > stdlib function in a way that cannot be added into the Go repository. You > will have to maintain that yourself, and it is brittle since the next > release will surely change it back. It is probably better to look for a way > to do custom formatting of a floating point value in your case. Although > I'd much rather leave it in scientific notation, were it me. > > On Sat, Mar 31, 2018 at 10:29 AM <[email protected] <javascript:>> > wrote: > >> found that >> >> https://golang.org/src/encoding/xml/marshal.go >> >> library contains >> >> return strconv.FormatFloat(val.Float(), 'g', -1, val.Type().Bits()), nil, nil >> >> >> where 'g' is for ('e' for large exponents, 'f' otherwise) >> >> Can anyone help to know how to do this internal library function >> modifications >> >> i.e to use 'f' instead of 'g' in marshal.go file of golang >> >> Thanks, >> >> Abhi >> >> >> >> On Friday, March 30, 2018 at 6:28:42 PM UTC+5:30, Abhijit Desai wrote: >>> >>> got this example - create a own number type and do custom marshalling of >>> Float >>> >>> https://play.golang.org/p/2moWdAwXrd >>> >>> But there are plenty of places where I used this Float64 directly and >>> not easy to change entire code base >>> >>> Can you please help me to handle this without creating own number >>> >>> Thanks, >>> >>> Abhi >>> >>> >>> -- >> 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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
