Re: [go-nuts] Re: Recover considered harmful

2017-04-25 Thread Bakul Shah
The practical issue here is how to use Go effectively to handle various error/exceptional situations. For that you have to first think about and understand these scenarios and the best way to handle them. But that is not simple and context dependent! Example: I may start up N threads in parallel

Re: [go-nuts] Re: Recover considered harmful

2017-04-25 Thread Юрий Соколов
`panic/recover` are really bad names for setjmp/longjmp. `throw/catch` are much closer. And C has `assert`. You may set handler for SIGABRT, but then you have to know what are you doing. Usually it is set for backtrace printing only. I mean: usual languages has clean separation between "wrong sta

Re: [go-nuts] Re: Recover considered harmful

2017-04-25 Thread Bakul Shah
Recover/panic need not be used only in case of a “critical” error. Just as in the case of setjmp/longjmp, there are other useful patterns. For example, a user may ask an interpreter to abandon its current computation by typing ^C. This would be handled by a longjmp/panic() to regain control at

Re: [go-nuts] Re: Recover considered harmful

2017-04-25 Thread Юрий Соколов
It looks like there is two point of view: - optimists who never used to build mutable shared state by them self, and they hope libraries they use also don't use mutable shared state, - and those who know that mutable shared state usually exists. In absence of mutable shared state it is perfectly

Re: [go-nuts] Re: Recover considered harmful

2017-04-25 Thread Kevin Conway
> To try to postpone the exit of a program after a critical error to me implies a much more complex testing and validation process that has identified all the shared state in the program and verified that it is correct in the case that a panic is caught There's an implicit argument here that the p

[go-nuts] Re: Recover considered harmful

2017-04-25 Thread Chris G
On Tuesday, April 25, 2017 at 7:52:25 PM UTC-7, Dave Cheney wrote: > > > Yes, and then crashes the program. In the scenario I described, with > thousands of other requests in flight that meet an abrubt end. That could > be incredibly costly, even if it's been planned for > > There are a host o

[go-nuts] Re: Recover considered harmful

2017-04-25 Thread Dave Cheney
> Yes, and then crashes the program. In the scenario I described, with > thousands of other requests in flight that meet an abrubt end. That could be > incredibly costly, even if it's been planned for There are a host of other reasons that can take a server offline abruptly. It seems like a od

[go-nuts] Re: Recover considered harmful

2017-04-25 Thread Chris G
On Tuesday, April 25, 2017 at 6:07:33 PM UTC-7, Dave Cheney wrote: > > > > On Wednesday, 26 April 2017 10:57:58 UTC+10, Chris G wrote: >> >> I think those are all excellent things to do. They do not preclude the >> use of recovering from a panic to assist (emphasis on assist - it is >> certainl

Re: [go-nuts] Interaction between Test and Benchmark functions?

2017-04-25 Thread Peter Fröhlich
Thank you David and Caleb, those were helpful suggestions, especially benchstat! Check out my conclusions though... :-/ I am running these four: $ go test -bench=. -count=10 >normal.txt $ go test -run=XXX -bench=. -count=10 >filter.txt $ go test -bench=. -count=10 >comment.txt $ go test -run=XXX -

[go-nuts] Re: Recover considered harmful

2017-04-25 Thread Dave Cheney
On Wednesday, 26 April 2017 10:57:58 UTC+10, Chris G wrote: > > I think those are all excellent things to do. They do not preclude the use > of recovering from a panic to assist (emphasis on assist - it is certainly > no silver bullet) in achieving fault tolerance. > > Assuming a web service th

[go-nuts] Re: Recover considered harmful

2017-04-25 Thread Chris G
I think those are all excellent things to do. They do not preclude the use of recovering from a panic to assist (emphasis on assist - it is certainly no silver bullet) in achieving fault tolerance. Assuming a web service that needs to be highly available, crashing the entire process due to one

Re: [go-nuts] Interaction between Test and Benchmark functions?

2017-04-25 Thread Caleb Spare
Hi Peter, Running your code locally (Go 1.8.1 / linux / amd64), I don't get a statistically significant difference between the two. The benchmark does generate a ton of garbage so the GC causes the benchmark runs to have a pretty decent variance. To check this kind of thing, you'll want to run th

Re: [go-nuts] [ANN] astilectron - Build cross platform GUI apps with GO and Electron (HTML/JS/CSS)

2017-04-25 Thread Tyler Compton
I gave the examples a run and I can confirm it works very well on Linux. Thank you for making this! Leveraging Electron as it is makes a lot of sense. On Tue, Apr 25, 2017 at 12:54 PM Asticode wrote: > Hi everyone, > > I'm happy to announce astilectron, a GO library to build cross platform GUI

[go-nuts] Re: Interaction between Test and Benchmark functions?

2017-04-25 Thread Dave Cheney
Yeah, you shouldn't combine benchmark and tests, use go test -run=XXX -bench=. To disable all tests (XXX matches nothing, you might prefer ^$) On Wednesday, 26 April 2017 09:48:29 UTC+10, Peter Froehlich wrote: > > Hi all, > > Sorry if this is an FAQ, but then my Google-foo has failed me. :-/

[go-nuts] Interaction between Test and Benchmark functions?

2017-04-25 Thread Peter Fröhlich
Hi all, Sorry if this is an FAQ, but then my Google-foo has failed me. :-/ It seems to me that the test functions in a bla_test.go file influence the benchmark functions in the same file. In the snippet below, if I comment out the body of the test function, I get better benchmark numbers than whe

[go-nuts] Problem installing Go on Solaris 10

2017-04-25 Thread Dave Cheney
Looking at the release notes for version 1.3, when Solaris support was added it look like you need Solaris 11 or a derivative. This probably explains the error from the dynamic loader. https://golang.org/doc/go1.3#solaris Solaris 10 support may be available in gccgo, I'm not aware of any or bu

[go-nuts] Recover considered harmful

2017-04-25 Thread Dave Cheney
Aside from arguments about using panic/recover to simulate longjmp inside recursive descent parsers I can think of no valid reason why recover should be used in production code. Imo, the arguments about wrapping all goroutines in a catch all recover are solving th wrong problem​. - if third p

[go-nuts] Problem with install Go on Solaris

2017-04-25 Thread carlogilmar12
Actually, I have trying to install go on solaris 10. The main problem is when I want to run go command, I got "go: Cannot find /libexec/ld-elf.so.1" GCC 4.9.2 Go free-bsd-386.tar Path its done. I can't understand this problem. If I go to usr/sfw/libexec directory, I found gcc directory and a g

[go-nuts] Problem installing Go on Solaris 10

2017-04-25 Thread Karlo Yilmar
I 've trying to install go 1.7 on Solaris 10. I can download the tar package, set the PATH, but when I want to run go command, I got this: "Cannot find /libexec/ld-elf.so.1" If I go to usr/sfw/libexec directory, I only found gcc folder, and other script. I don't know what is the problem. Thank

Re: [go-nuts] Recover considered harmful

2017-04-25 Thread Dan Kortschak
On Tue, 2017-04-25 at 03:06 +, Kevin Conway wrote: > The convention in the Go libraries is that even when a package uses > panic internally, its external API still presents explicit error > return values. reflect? All rules are wrong. -- You received this message because you are subscribed

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Egon
On Tuesday, 25 April 2017 23:25:14 UTC+3, Tong Sun wrote: > > > On Tue, Apr 25, 2017 at 3:42 PM, Egon wrote: > > I think the extra "enum" package would reduce readability. The code you >> are putting into package is ~10 lines of code... so the extra package >> doesn't reduce much typing, but it

Re: [go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Tong Sun
On Tue, Apr 25, 2017 at 3:42 PM, Egon wrote: I think the extra "enum" package would reduce readability. The code you are > putting into package is ~10 lines of code... so the extra package doesn't > reduce much typing, but it also loses enum typing... Depending on the enum, > you may want to have

[go-nuts] [ANN] astilectron - Build cross platform GUI apps with GO and Electron (HTML/JS/CSS)

2017-04-25 Thread Asticode
Hi everyone, I'm happy to announce astilectron, a GO library to build cross platform GUI apps in HTML/JS/CSS: https://github.com/asticode/go-astilectron I needed a way to build a cross platform GUI app in GO but none of the projects out there were meeting my needs (they were either only MacOS

[go-nuts] Re: How to do OS Authentication in Oracle with Go?

2017-04-25 Thread Tieson Molly
Tamás, I was looking for a way to have the OS handle the authentication for the Oracle connection. That is one of the options where you pass an empty username and password. Didier provided a detailed link from Oracle. On Friday, April 21, 2017 at 5:35:04 PM UTC-4, Tamás Gulácsi wrote: > > W

[go-nuts] Re: How to do OS Authentication in Oracle with Go?

2017-04-25 Thread Tieson Molly
Yes, this is exactly what I mean. On Saturday, April 22, 2017 at 3:21:30 AM UTC-4, Didier Spezia wrote: > > > The OP probably means connecting to Oracle from an "externally identified" > user. > Oracle can delegate the authentication to the OS providing the connection > is done from > a given OS

[go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Egon
I think the extra "enum" package would reduce readability. The code you are putting into package is ~10 lines of code... so the extra package doesn't reduce much typing, but it also loses enum typing... Depending on the enum, you may want to have different properties as well... I chose the name

[go-nuts] Re: Assign a string representation to an enum/const

2017-04-25 Thread Tong Sun
Hi, I've convert Egon's idea into a package, https://github.com/suntong/enum. It works fine for a single enum case, see the demo in https://github.com/suntong/enum. However, now I need to define different series of enums, and I'm wondering what the best way to do it. I tried to give the pack

Re: [go-nuts] [ANN] sqlite

2017-04-25 Thread Andy Balholm
This discussion piqued my interest, and I decided to see what I could do to make rsc.io/c2go more general-purpose. My fork is at github.com/andybalholm/c2go . I think that, with appropriate .h and .cfg files, it can now handle the tests fr

Re: [go-nuts] Is the case 2 equivalent to case 1 or case 3 in this example?

2017-04-25 Thread T L
On Tuesday, April 25, 2017 at 9:46:42 PM UTC+8, Ian Lance Taylor wrote: > > On Tue, Apr 25, 2017 at 5:22 AM, T L > > wrote: > > > > package main > > > > import ( > > "unsafe" > > ) > > > > func alignment(p *int64) uintptr { > > return unsafe.Alignof(*p) > > // compiler does

Re: [go-nuts] Recover considered harmful

2017-04-25 Thread Micky
As Rob Pike said, if you don't let the real reason behind "panicing" die, then recovering is most logical thing to do in times of dire need! For instance, the Caddy server routinely uses *recover* to recover from panics but responsibily logs them during ServeHTTP because it has to provide ultimate

Re: [go-nuts] Recover considered harmful

2017-04-25 Thread Sam Whited
On Mon, Apr 24, 2017 at 10:06 PM, Kevin Conway wrote: > In this example we're considering panic as a mechanism of preventing > otherwise avoidable code bugs. What happens when the same code begins > silencing panics and continuing on? Then the application author has explicitly said "I don't care

Re: [go-nuts] Is the case 2 equivalent to case 1 or case 3 in this example?

2017-04-25 Thread Ian Lance Taylor
On Tue, Apr 25, 2017 at 5:22 AM, T L wrote: > > package main > > import ( > "unsafe" > ) > > func alignment(p *int64) uintptr { > return unsafe.Alignof(*p) > // compiler doesn't know if *p is a field or a variable. > // so compiler will treat *p as a variable, I think. > } > > type

Re: [go-nuts] Re: [Help] Seeing an occasional data race on a closed channel

2017-04-25 Thread Owen Waller
Hi David, Ah ha, magic. And all fixed. Sometimes another pair of eyes is all that is required. While I had no doubt the race detector was correct in reporting the race the key line in the reply was "The only goroutine that can safely close a channel is the one that is writing to it." After that ev

Re: [go-nuts] Re: Is everything passed as a value in Go?

2017-04-25 Thread ojucie
Go is meant to be fast. The choice for pass by value or by reference for each embedded type was carefully chosen having that in mind. Pass by value reduces the heap usage because function calls can make a value copy instead of keeping the value at the heap. Whenever a value is passed by reference

[go-nuts] Re: Golang and x509 with GOST

2017-04-25 Thread 014730
среда, 9 июля 2014 г., 21:26:55 UTC+3 пользователь agl написал: > > On Wednesday, July 9, 2014 4:39:30 AM UTC-7, Vladislav Egorov wrote: >> >> Someone tell me how to work in a Golang with X509 certificates and >> cryptography Russian GOST (CryptoPro CSP), which can have a library, or who >> hav

Re: [go-nuts] Re: Find a string in a file and delete all occurences in the file

2017-04-25 Thread Michael Jones
Sure. Here's a slightly expanded example. https://play.golang.org/p/bfKFrATI0q On Tue, Apr 25, 2017 at 5:20 AM, Vikas Kumar wrote: > Thanks a ton Michael and Ishan. Let me understand the code and use this in > my program. > > Cheers, > Vikas > > -- > You received this message because you are sub

[go-nuts] Is the case 2 equivalent to case 1 or case 3 in this example?

2017-04-25 Thread T L
package main import ( "unsafe" ) func alignment(p *int64) uintptr { return unsafe.Alignof(*p) // compiler doesn't know if *p is a field or a variable. // so compiler will treat *p as a variable, I think. } type T struct { x int64 } func main() { var t T println( ali

Re: [go-nuts] Re: Find a string in a file and delete all occurences in the file

2017-04-25 Thread Vikas Kumar
Thanks a ton Michael and Ishan. Let me understand the code and use this in my program. Cheers, Vikas -- 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

Re: [go-nuts] Set a SAN otherName using `x509.CertificateRequest`

2017-04-25 Thread Adam Medziński
I figured this out. Now I have a problem with correctly marshalling this field. Here is a link to the example code: Go Playground It creates certificate request without error but requested extensions are total mess: Certificate Request: Data:

[go-nuts] Re: Dynamic type assertion for interface

2017-04-25 Thread Nathan Kerr
Thanks for providing code! What is CopyStruct intended to do? On Monday, April 24, 2017 at 6:33:58 PM UTC+2, Rajesh kumar wrote: > > Please do note that the structs in this example is a sample.My struct is > complex than this. > https://play.golang.org/p/_t7gx3javb > Here I have a function wher

[go-nuts] Re: database/sql left join best practicea for null values

2017-04-25 Thread 'slinso' via golang-nuts
Forgot to mention that I currently use MySQL with go-sql-driver. Another solution would be to use mymysql as a driver. That one maps null values to go type default zero values. But I wanted to stick to go-sql-driver because I think it is more actively maintained. -- You received this message b

[go-nuts] database/sql left join best practicea for null values

2017-04-25 Thread 'slinso' via golang-nuts
What's a nice way to handle left joins with database/sql? Imagine you have a users who can optional have an image. So you have an optional 1:1 relationship. Example: type User struct { ID int Loginname string Password string ImageIDint // or sql.NullInt depends on your DB