Re: [go-nuts] Is len() shadowed in crypto/sha256?

2018-01-14 Thread Ian Lance Taylor
On Sun, Jan 14, 2018 at 9:15 AM, Dan Lüdtke wrote: > > looking for some insights regarding Sum256, especially line 139. > https://golang.org/src/crypto/sha256/sha256.go?#L139 > Doesn't the statement `len := d.len` shadow the len() function and isn't > that supposed to be "bad style" or am I missin

[go-nuts] Update your code if you use golang.org/x/crypto/acme/autocert

2018-01-14 Thread alex
If you use the autocert package, please update your code: you'll want to add Manager.HTTPHandler[1] call to support "http-01" challenge type. Unfortunately, this requires listening and accepting requests on port 80 for the time being. See Manager example. Commit which adds "http-01" support to

[go-nuts] Is len() shadowed in crypto/sha256?

2018-01-14 Thread Dan Lüdtke
Hi, looking for some insights regarding Sum256, especially line 139. https://golang.org/src/crypto/sha256/sha256.go?#L139 Doesn't the statement `len := d.len` shadow the len() function and isn't that supposed to be "bad style" or am I missing something here? If it is shadowing, is this OK to do

[go-nuts] Measuring low latency operations

2018-01-14 Thread asaaveri
All: I am testing an application that has a latency of the order of few to several microseconds. I wrote a benchmark and measured the performance. I also computed the elapsed time using time.Now() and time.Since(). (I will change this to time,Nanoseconds and try shortly. I found the compute

[go-nuts] Re: How to implement Segment Tree in key/value datastore to use Google S2 geometry?

2018-01-14 Thread Constantine Vassilev
Thanks for the suggestion and the link. The question is how it will be searched. Also I liked the Google S2's Golang implementation. >From the documentation if the link I see: -- Queries Bounding-box and k-nearest-neighbors queries are supported. Bounding-box queries require a search *Rect. It

Re: [go-nuts] Is there a mistake in the "Expression statements" section of Go spec?

2018-01-14 Thread digg
On Sunday, January 14, 2018 at 10:14:21 AM UTC-5, Axel Wagner wrote: > > Why not? The linked Expression section (more specifically, the Expression > *rule*) defines the format of expressions. An expression statement allows > you to use any expression also as a statement; this is important, beca

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
On Sunday, January 14, 2018 at 6:01:39 AM UTC-5, Jan Mercl wrote: > > On Sun, Jan 14, 2018 at 5:37 AM > wrote: > > > I have a parent/child class ... > > You don't. No classes, no parents, no children. You need to make your > design work with Go. In most cases you cannot make Go work like languag

Re: [go-nuts] Is there a mistake in the "Expression statements" section of Go spec?

2018-01-14 Thread 'Axel Wagner' via golang-nuts
Why not? The linked Expression section (more specifically, the Expression *rule*) defines the format of expressions. An expression statement allows you to use any expression also as a statement; this is important, because it means you can, e.g. write fmt.Println("foobar") as an expression (without

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
I'm not sure I understand the question correctly. You *can* use the variable in the switch block (i.e. in the indvidual cases). But maybe these two quotes from the spec answer your question nevertheless: Quote 1 : Each clause in a "switch" or "select" statement

[go-nuts] Is there a mistake in the "Expression statements" section of Go spec?

2018-01-14 Thread dg
In this section, it shows ExpressionStmt = Expression . However, it looks the content in this section has nothing related to the linked Expression section. -- You received this message because you are subscribed to the Google Groups "golang-nuts" gro

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
Thanks Axel. The examples make it very clear. https://play.golang.org/p/fSLw3R_tujV So what's the differences between the implicit block around the switch statement and if statement (or loop-variables)? -- - the variables defined in the if statement's implici

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
Go does not allow declaring the same identifier in one scope twice, but there is an implicit block around the switch statement. This is the same mechanism by which loop-variables are scoped. So it is functionally equivalent to this

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Tong Sun
Thanks Axel. One question, how come the following would even compile? func setf(p Parenter) { switch p := p.(type) { case Child: p.Attr2 = "foo" case Child2: p.Attr3 = "foo" } } I.e., in setf(), we have two `p`s with different types, how can it be even possible with Go? -- I thought Go

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread 'Axel Wagner' via golang-nuts
As others have mentioned, the lingo is wrong (there is no inheritance in Go), but this is how you can make your specific code work as intended: https://play.golang.org/p/LVE8gFDtAM7 On Sun, Jan 14, 2018 at 3:08 PM, wrote: > Use the interface type assertion or type switch: https://tour.golang. >

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread matthewjuran
Use the interface type assertion or type switch: https://tour.golang.org/methods/16 Matt On Sunday, January 14, 2018 at 5:01:39 AM UTC-6, Jan Mercl wrote: > > On Sun, Jan 14, 2018 at 5:37 AM > wrote: > > > I have a parent/child class ... > > You don't. No classes, no parents, no children. You ne

Re: [go-nuts] embedding - Access child struct elements by type casting

2018-01-14 Thread Jan Mercl
On Sun, Jan 14, 2018 at 5:37 AM wrote: > I have a parent/child class ... You don't. No classes, no parents, no children. You need to make your design work with Go. In most cases you cannot make Go work like languages supporting classes and inheritance. -- -j -- You received this message b

Re: [go-nuts] http.FileServer: how to serve static files requested from different domains?

2018-01-14 Thread Ayan George
On 01/13/2018 11:26 PM, Constantine Vassilev wrote: > Here is how I implemented it: > Well -- just to be clear: I think my solution is wrong. I didn't understand how http.ServeMux worked: https://golang.org/pkg/net/http/#ServeMux Andy Balholm pointed out that http.Handle() can accept a do