Re: [go-nuts] What Go devs think about issues described by Daniel Lemire in article "The Go compiler needs to be smarter"?

2020-06-04 Thread Michael Jones
When he writes "you expect a good, optimizing compiler to..." he is implicitly stating that he wants more than good optimizing compilation, he wants (understandably, but let's be explicit) iterated compile-time evaluation -- he wants fun() to be an integer value of 60. It is true that the gc Go

[go-nuts] Re: SSL socket listener

2020-06-04 Thread Manlio Perillo
See https://golang.org/pkg/crypto/tls/#Conn about how to make a secure network connection. There is an example for the Dial function. For the normal network API see https://golang.org/pkg/net/ Manlio Il giorno mercoledì 3 giugno 2020 alle 09:20:12 UTC+2 Wesley Peng ha scritto: > Hello, > >

Re: [go-nuts] What Go devs think about issues described by Daniel Lemire in article "The Go compiler needs to be smarter"?

2020-06-04 Thread Andy Balholm
I think by “at compile time” he means at JIT time (when converting bytecode to machine language). Andy > On Jun 4, 2020, at 1:02 PM, Robert Engels wrote: > > The author either doesn’t know Java or had significant editing errors - Java > determines uses the runtime processor type to

Re: [go-nuts] What Go devs think about issues described by Daniel Lemire in article "The Go compiler needs to be smarter"?

2020-06-04 Thread Robert Engels
The author either doesn’t know Java or had significant editing errors - Java determines uses the runtime processor type to optimize - it is not done at compiler time. It has different implementations based on processor - like Go - and it does JIT optimizations based on processor as well. More

Re: [go-nuts] What Go devs think about issues described by Daniel Lemire in article "The Go compiler needs to be smarter"?

2020-06-04 Thread Ian Lance Taylor
On Thu, Jun 4, 2020 at 12:34 PM Igor Yemelianov wrote: > > The question is - is it possible that the issues described in the article can > be solved in for example next major version? Yes, it is possible. As Go is an open source project, you or anyone can make that much more likely to happen

Re: [go-nuts] x, err = some_func(); if err != nil { } seems awkward

2020-06-04 Thread Ian Lance Taylor
On Thu, Jun 4, 2020 at 8:43 AM wrote: > > ?? Why not a cleaner syntax e.g. x = some_func () #{ } .. symbol # > arbitrarily chosen Besides what other people have said, it may be of interest to glance through https://github.com/golang/go/issues?q=is%3Aissue+label%3Aerror-handling . Ian --

[go-nuts] What Go devs think about issues described by Daniel Lemire in article "The Go compiler needs to be smarter"?

2020-06-04 Thread Igor Yemelianov
Link to the article. The question is - is it possible that the issues described in the article can be solved in for example next major version? Thanks. -- You received this message because you are subscribed to the

[go-nuts] Re: x, err = some_func(); if err != nil { } seems awkward

2020-06-04 Thread Saied Seghatoleslami
There is also the idea that an error is not necessarily an error in the sense that it is wrong but it is something that prevents the operation. It could be that the far end is out of service or the network connection is down or the port is closed or the file permissions are set to what is not

Re: [go-nuts] x, err = some_func(); if err != nil { } seems awkward

2020-06-04 Thread Michael Jones
Before you get an avalanche of emails about "that is an old question, discussed in design documentation, mailing lists, and extension discussions over a decade", let me ask you to consider a concept that your comment implies. For that to work, it means that a function call either succeeds or

[go-nuts] Re: Assignment of pointer values in a struct...

2020-06-04 Thread eric . brown
When you need to differentiate between nil and and empty string (because whatever you're assigning to, a "" may be valid). For lack of time (and going into detail myself), here's a write-up on a reason why: https://dhdersch.github.io/golang/2016/01/23/golang-when-to-use-string-pointers.html

[go-nuts] trouble parsing XML with embedded structs

2020-06-04 Thread Lars R. Damerow
Hello all, I need to parse XML messages from a source I don't control. Each one has an envelope node that shows its source, and the first node in that envelope encodes the message type. I'm trying to compose structs to make it easier to do the parsing, and I put a stripped-down example for

[go-nuts] x, err = some_func(); if err != nil { } seems awkward

2020-06-04 Thread lgodio2
?? Why not a cleaner syntax e.g. x = some_func () #{ } .. symbol # arbitrarily chosen -- 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

Re: [go-nuts] Assignment of pointer values in a struct...

2020-06-04 Thread Jan Mercl
On Thu, Jun 4, 2020 at 5:13 PM Trig wrote: > > And I did it again... posted from another gmail account by accident, and my > post is forever in 'approval status', lol. Basically what Robert here said. > > On Thursday, June 4, 2020 at 9:53:56 AM UTC-5, Robert Engels wrote: >> >> You need

Re: [go-nuts] Assignment of pointer values in a struct...

2020-06-04 Thread Trig
And I did it again... posted from another gmail account by accident, and my post is forever in 'approval status', lol. Basically what Robert here said. On Thursday, June 4, 2020 at 9:53:56 AM UTC-5, Robert Engels wrote: > > You need pointers to strings if you need a nil value to be represented

Re: [go-nuts] Assignment of pointer values in a struct...

2020-06-04 Thread Robert Engels
You need pointers to strings if you need a nil value to be represented which is often the case in databases. > On Jun 4, 2020, at 9:30 AM, Saksham Saxena wrote: > > Yep perfectly fine. MongoDB Driver for Go also uses such a wrapper at many > places where it takes a string as an argument and

[go-nuts] Assignment of pointer values in a struct...

2020-06-04 Thread Saksham Saxena
Yep perfectly fine. MongoDB Driver for Go also uses such a wrapper at many places where it takes a string as an argument and returns a pointer to it which is required internally. Not really sure why use a pointer to strings in Go because they're immutable, but I guess to reach their own. --

[go-nuts] Re: Assignment of pointer values in a struct...

2020-06-04 Thread Jake Montgomery
Trig, I'm very curious why you want to use a pointer to a string? Since strings are immutable, and already are like "pointers" internally, I have rarely, if ever, used *string in go. What is it that you achieve by doing this? - Jake On Wednesday, June 3, 2020 at 10:33:31 PM UTC-4, Trig

Re: [go-nuts] SSL socket listener

2020-06-04 Thread Brian Candler
https://golang.org/pkg/crypto/tls/#example_LoadX509KeyPair sets up a basic listener. Once you have this, it's just like a normal socket accept. See https://golang.org/pkg/net/#example_Listener for how to accept connections and handle them in their own goroutines. -- You received this message

Re: [go-nuts] SSL socket listener

2020-06-04 Thread 'Wesley Peng' via golang-nuts
Thanks. how about the sample of general socket listener with SSL rather than net/http implementation? Regards Dimas Prawira wrote: Here is an example running server with TLS package main import ( "net/http" "log" ) func HelloServer(w http.ResponseWriter,req *http.Request) {