[go-nuts] Experience report on a large Python-to-Go translation

2020-01-25 Thread Eric Raymond
Most of the remainder of this post is asciidoc source, because that's easy to quote. If you want to look at a nicely rendered version, see https://gitlab.com/esr/reposurgeon/blob/master/GoNotes.adoc = Notes on the Go translation of Reposurgeon = version 1.8, 2020-01-25 This is an experience re

Re: [go-nuts] link order in executable

2020-01-25 Thread 'Michael Stiller' via golang-nuts
Thank you Ian. Best regards, Michael > On 24. Jan 2020, at 22:19, Ian Lance Taylor wrote: > > On Fri, Jan 24, 2020 at 1:10 PM 'Michael Stiller' via golang-nuts > wrote: >> >> playing around with tamago i noticed that if i compile with this command: >> >> GO_EXTLINK_ENABLED=0 CGO_ENABLED=0

[go-nuts] Re: Experience report on a large Python-to-Go translation

2020-01-25 Thread Brian Candler
Very insightful. I am relatively new to go, but I would like to make a few observations. 1. When the issue of keyword arguments has come up before, usually someone suggests passing a struct as the function argument. Did you try this? It might be worth mentioning in your analysis, if only to g

Re: [go-nuts] Re: Experience report on a large Python-to-Go translation

2020-01-25 Thread Robert Engels
Very in-depth and interesting. Although I agree with most of the points, I think a better use of interfaces would address some of your concerns, and have more maintainable code. Whenever I see a type switch it screams to me “use an interface and restructure. “ >> On Jan 25, 2020, at 4:43 AM

[go-nuts] Can anyone explain this code Please. It is not giving expected result.

2020-01-25 Thread Kaleemullah Software Engineer
When i change the value U at 0 index , It changes the value of t and u at zero index why it is not changing the value of S. Please Explain I got stuck here. package main import ( "fmt" ) func main() { var s []int var t []int s= make([]int,3) s[0]=100 s[1]=200 s[2]=300 t=append(s,400) fmt

Re: [go-nuts] Can anyone explain this code Please. It is not giving expected result.

2020-01-25 Thread burak serdar
On Sat, Jan 25, 2020 at 9:55 AM Kaleemullah Software Engineer wrote: > > > When i change the value U at 0 index , It changes the value of t and u at > zero index why it is not changing the value of S. Please Explain I got stuck > here. > > > > > package main > > import ( > "fmt" > ) > > func mai

Re: [go-nuts] Can anyone explain this code Please. It is not giving expected result.

2020-01-25 Thread Ian Lance Taylor
On Sat, Jan 25, 2020 at 9:15 AM burak serdar wrote: > > On Sat, Jan 25, 2020 at 9:55 AM Kaleemullah Software Engineer > wrote: > > > > > > When i change the value U at 0 index , It changes the value of t and u at > > zero index why it is not changing the value of S. Please Explain I got > > stu

Re: [go-nuts] Re: Experience report on a large Python-to-Go translation

2020-01-25 Thread Eric Raymond
On Saturday, January 25, 2020 at 10:04:19 AM UTC-5, Robert Engels wrote: > > Whenever I see a type switch it screams to me “use an interface and > restructure. “ > You may be right. On the other hand, I think I've already gone far enough down the interface road to have collected most of the ga

[go-nuts] Re: Experience report on a large Python-to-Go translation

2020-01-25 Thread Eric Raymond
On Saturday, January 25, 2020 at 5:43:24 AM UTC-5, Brian Candler wrote: > > 1. When the issue of keyword arguments has come up before, usually someone > suggests passing a struct as the function argument. Did you try this? It > might be worth mentioning in your analysis, if only to give an ex

[go-nuts] Printing *go/ast.CommentGroup

2020-01-25 Thread Shane H
Hi all, I'm trying to learn how to write a linter (because long weekend, etc) I looked at Fatih's very fine blog post ( https://arslan.io/2019/06/13/using-go-analysis-to-write-a-custom-linter/) as well as the one that precedes it, although I was a LOT lost reading that one. Copying and pasting

[go-nuts] keep just 2 decimal places in a float64

2020-01-25 Thread Jason E. Aten
https://play.golang.org/p/87bDubJxjHO I'd like to truncate a float64 to just 2 decimal places (in base 10), but math.Trunc is not helping me here... ideally I put 0.29 in and I get 0.29 out. Suggestions? Playground examples appreciated. package main import ( "fmt" "math" ) // truncate off e

Re: [go-nuts] keep just 2 decimal places in a float64

2020-01-25 Thread Kurtis Rader
You've fallen into a common trap. Base 2 floating point values cannot represent most decimal values precisely. This is why you should never, ever, do a simple equality test involving a F.P. value derived from a calculation. You always have to apply an epsilon to define a range within which the two

Re: [go-nuts] keep just 2 decimal places in a float64

2020-01-25 Thread Aston Motes
Picking the first decimal library on pkg.go.dev, what about https://play.golang.org/p/Co96HKlvSMp ? On Sat, Jan 25, 2020 at 7:34 PM Kurtis Rader wrote: > You've fallen into a common trap. Base 2 floating point values cannot > represent most decimal values precisely. This is why you should never,

[go-nuts] Re: keep just 2 decimal places in a float64

2020-01-25 Thread cratermoon
Floating point math has many pitfalls. https://play.golang.org/p/LK0lla8hM9w See also https://0.30004.com/ s On Saturday, January 25, 2020 at 7:14:15 PM UTC-8, Jason E. Aten wrote: > > > https://play.golang.org/p/87bDubJxjHO > > I'd like to truncate a float64 to just 2 decimal plac

Re: [go-nuts] Re: keep just 2 decimal places in a float64

2020-01-25 Thread Kurtis Rader
On Sat, Jan 25, 2020 at 9:26 PM wrote: > Floating point math has many pitfalls. > https://play.golang.org/p/LK0lla8hM9w See also > https://0.30004.com/ > I was not aware of URL https://0.30004.com/. Like the XY problem URL, http://xyproblem.info/, the URL you cited is ano

Re: [go-nuts] keep just 2 decimal places in a float64

2020-01-25 Thread Jamil Djadala
On Sat, 25 Jan 2020 19:14:15 -0800 (PST) "Jason E. Aten" wrote: > > https://play.golang.org/p/87bDubJxjHO > > I'd like to truncate a float64 to just 2 decimal places (in base 10), > but math.Trunc is not helping me here... ideally I put 0.29 in and I > get 0.29 out. > Suggestions? Playground e

Re: [go-nuts] keep just 2 decimal places in a float64

2020-01-25 Thread Robert Engels
You can use github.com/robaho/fixed :) > On Jan 25, 2020, at 11:40 PM, Jamil Djadala wrote: > > On Sat, 25 Jan 2020 19:14:15 -0800 (PST) > "Jason E. Aten" wrote: > >> >> https://play.golang.org/p/87bDubJxjHO >> >> I'd like to truncate a float64 to just 2 decimal places (in base 10), >> but