[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread dc0d
Well said! Still I prefer functions to comments, when possible. As it's been said, code never lies, comments sometimes do. And a boom is simpler to understand (for me). Functions go boom; comments do not. On Saturday, August 12, 2017 at 1:48:05 AM UTC+4:30, Egon wrote: > > There are no good

Re: [go-nuts] Why does vet's 'rangeloop' check only check the last statement of a loop?

2017-08-11 Thread Ian Lance Taylor
On Thu, Aug 10, 2017 at 1:43 PM, wrote: > > Yes, it makes sense that it would be impossible to really check at that > level. What surprised me was that this does not trigger vet: > > for i := range slice { > go f(i) > _ = 1 > } > > Yet this does trigger vet: > > for i

[go-nuts] golang.org/x/crypto/ssh hangs when connecting to some servers

2017-08-11 Thread Philip Stein
Hello, I'm working on a utility that uses the golang.org/x/crypto/ssh library to connect to about 100 servers. Most of the connections work fine, but there are 6 servers where the connection hangs during the ssh.Dial. Using delve, I've been able to track it down to clientAuthenticate in

[go-nuts] atomic package pointer operations with maps and channels

2017-08-11 Thread Josh Humphries
It is possible to extract a map's actual value/address if it is stored in the heap -- by using something like this: atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer())) However, it does not appear to possible to go the other direction, even if using unsafe. Specifically, to take an

[go-nuts] Go 2.0 proposal: context scoped variables

2017-08-11 Thread Sam Vilain
Many have written about this; there's an index on Go wiki under ExperienceReports#context including my own writing for the 2016 advent calendar. I would like to propose a simpler way to solve the "optional variable access" part of

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread dc0d
Thanks for suggesting guru. I'll try it. If there is a convention for naming, it makes code more clear, otherwise, yes, it makes code more unclear - in my experience. In times it's not an easy task. But having a long function too, is not a good thing (IMHO). On Friday, August 11, 2017 at

Re: [go-nuts] (Un)Expected compiler behavior on named/unnamed parameters of interface functions

2017-08-11 Thread Ian Lance Taylor
On Fri, Aug 11, 2017 at 11:51 AM, Penguin Enormous wrote: > My eyes has just been opened. Silly me, I get it now. Thank you very much. > > May I ask which section in the Language Specification mention this allowance > of int (or float64, ... etc.) for use as identifier

Re: [go-nuts] (Un)Expected compiler behavior on named/unnamed parameters of interface functions

2017-08-11 Thread Penguin Enormous
My eyes has just been opened. Silly me, I get it now. Thank you very much. May I ask which section in the Language Specification mention this allowance of int (or float64, ... etc.) for use as identifier names? On Saturday, August 12, 2017 at 1:30:04 AM UTC+7, Ian

Re: [go-nuts] (Un)Expected compiler behavior on named/unnamed parameters of interface functions

2017-08-11 Thread Ian Lance Taylor
On Fri, Aug 11, 2017 at 11:03 AM, Penguin Enormous wrote: > > I think that there is inconsistency in the way Go compiler report error > regarding name/unnamed parameters. This is a bit hard for me to explain in > words so please check out this short snippet first: > >

Re: [go-nuts] Why can't we do timer related works in sysmon rather than another timer goroutine?

2017-08-11 Thread Ian Lance Taylor
On Thu, Aug 10, 2017 at 10:32 PM, Cholerae Hu wrote: > Currently if we use timer or something, runtime will start a new goroutine > to do timerproc works. Why can't we check timer heap in each iteration of > sysmon if any timer exists? This may reduce some context switchs,

[go-nuts] (Un)Expected compiler behavior on named/unnamed parameters of interface functions

2017-08-11 Thread Penguin Enormous
I think that there is inconsistency in the way Go compiler report error regarding name/unnamed parameters. This is a bit hard for me to explain in words so please check out this short snippet first: https://play.golang.org/p/Sg0DtCtgF2 Is this unexpected behavior or it's just me that's feeling

Re: [go-nuts] how can I decrypt "ENCRYPTED PRIVATE KEY" using golang

2017-08-11 Thread Konstantin Khomoutov
On Fri, Aug 11, 2017 at 12:30:56AM -0700, terry.an...@gmail.com wrote: > My private key is generated by "openssl req -new -x509 -keyout a.key -out > a.crt -days 3650" with password. > > And I tried to decrypted it by x509.DecryptPEMBlock(keyBlock, password), > but failure. error message:

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread Egon
Note, this can fragment the code and make it harder to understand... (http://number-none.com/blow/john_carmack_on_inlined_code.html) As for the tool: guru can give you the callers of a function, so you might be able to derive something from it. + Egon On Friday, 11 August 2017 10:39:16

[go-nuts] how can I decrypt "ENCRYPTED PRIVATE KEY" using golang

2017-08-11 Thread terry . an . bj
My private key is generated by "openssl req -new -x509 -keyout a.key -out a.crt -days 3650" with password. And I tried to decrypted it by x509.DecryptPEMBlock(keyBlock, password), but failure. error message: %!(EXTRA *errors.errorString=x509: no DEK-Info header in block) my privatekey is in

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread dc0d
As he cleared up in his later quotes and tweets it's about replacing comments with functions. IMHO this way comments will turn into active (code) specifications and would help greatly specially in a statically types languages. They might even make writing more clear tests easier. But (IMHO)

Re: [go-nuts] Go channels overused and hyped?

2017-08-11 Thread Chris Hopkins
[sorry for the side question but:] When there is the "channels are expensive" consideration, I assume that is from a latency perspective rather than a throughput perspective. i.e. it was my understanding that channels had a small overhead on top of a basic lock, but otherwise added very little

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread Henry
I am not aware of any such tools exist. You may need to roll out your own. However, don't you think that the purpose of Fowler,et al. proposing such guideline is to encourage function reuse? On Friday, August 11, 2017 at 2:39:16 PM UTC+7, dc0d wrote: > "When you feel the need to write a

Re: [go-nuts] Regexp documentation error?

2017-08-11 Thread Jesse McNelis
On Fri, Aug 11, 2017 at 9:03 PM, Jens Hausherr wrote: > I see, > > I was just confused by the fact that fmt.Printf("%q/%v") apparently renders > a nil array as an empty array ([]) while rendering other nil values (e.g. > pointers) as . Yep, a nil slice is also an empty

Re: [go-nuts] Go channels overused and hyped?

2017-08-11 Thread Jesper Louis Andersen
On Tue, Aug 8, 2017 at 8:01 AM snmed wrote: > > I stumbled over a nice and very interesting Blog entry "Go channels are > bad and you should feel bad > " > , I would like to hear some

Re: [go-nuts] godoc.or is unreachable from Germany

2017-08-11 Thread Jan Mercl
On Fri, Aug 11, 2017 at 11:47 AM Norbert Fuhs wrote: > it seems https://godoc.org/ is unreachable from Germany. Works from Germany now. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] Regexp documentation error?

2017-08-11 Thread Jan Mercl
On Fri, Aug 11, 2017 at 12:43 PM Jens Hausherr wrote: > Is the documentation wrong in this case or am I just missing the case where nil is returned? The docs are correct: https://play.golang.org/p/6fiID64IAt -- -j -- You received this message because you are

[go-nuts] Regexp documentation error?

2017-08-11 Thread Jens Hausherr
Hi, I was using some Regexp and noted that all functions are documented to return 'nil' if the RE does not match. I was using FindSubmatchString(s string) ad got an empty string array when the expression did not match a string. Example: https://play.golang.org/p/_kSYXM5e_j Is the

[go-nuts] Re: Why can't we do timer related works in sysmon rather than another timer goroutine?

2017-08-11 Thread Chris Hopkins
I had written a really long answer, but I suspect I may be misunderstanding what you are proposing. (Apologies if I misunderstand you here, but if I am misunderstanding you, then my long answer would have been even more patronising than i worry this already is.) You have some code you wish to

Re: [go-nuts] godoc.or is unreachable from Germany

2017-08-11 Thread Henrik Johansson
Not just there. I got internal server error. On Fri, 11 Aug 2017, 11:47 Norbert Fuhs, wrote: > Hi, > > it seems https://godoc.org/ is unreachable from Germany. > > Its also noted on Go Forums: > https://forum.golangbridge.org/t/godoc-org-is-down/6265 > > > -- > You

[go-nuts] godoc.or is unreachable from Germany

2017-08-11 Thread Norbert Fuhs
Hi, it seems https://godoc.org/ is unreachable from Germany. Its also noted on Go Forums: https://forum.golangbridge.org/t/godoc-org-is-down/6265 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Re: Code Review - Applying functions on custom types

2017-08-11 Thread Egon
I've suggested this approach based in the slack, adding it here as well to make it searchable. Implement Reader/Writer such that you can do: func ProcessLine(in *Reader, out *Writer) error { start, finish, participant := in.Float64(), in.Float64(), in.String() if err := in.Err(); err !=

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread dc0d
"When you feel the need to write a comment, first try to refactor the code so that any comment becomes superfluous." - Martin Fowler, Kent Beck, John Brant, William Opdyke, and Don Roberts (1999) Refactoring: Improving the Design of Existing Code. Addison-Wesley. Based on this practice, the