[go-nuts] Autocert behavior for IP address lookups?

2022-01-31 Thread James Wendel
I made a cache client for autocert that has been working fine, but I noticed something odd in my logs. Specifically, I am seeing calls against Autocert's Cache.Get(...) method (CS link

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread Robert Engels
If I hired on to a company that enforced 3-4 line function calls I would be looking for a job the next day. > On Jan 31, 2022, at 6:44 PM, Rick wrote: > > Really? The idea that functions should never be longer than 2-3 lines is > absurd. Functions should take an input, do one thing (without

[go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread Rick
Really? The idea that functions should *never* be longer than 2-3 lines is absurd. Functions should take an input, do one thing (without side-effect) and return a result. And their name should indicate what function they compute. Whether that is 2-3 lines or 20-30 lines depends on the function.

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread Rudolf Martincsek
> for _, otter := ListRiverOtters("europe") > Calling this variable "otter" is great. Calling it "europeanRiverOtter" is absurd - that's already there, obviously in the code. Your "absurd" example is too charitable and naive. That's not even bad compared to what I encounter day by day. Some wou

[go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread Rudolf Martincsek
> Agree with Rudolf on point 2. Then you completely misunderstood my point. Because I said exactly the opposite. If your variable names are 10-15 words long (including prepositions) then you should document what the function does. On Saturday, January 29, 2022 at 1:21:19 PM UTC+2 timphar...@gmai

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-31 Thread 'Thomas Bushnell BSG' via golang-nuts
On Fri, Jan 28, 2022 at 1:12 PM Rudolf Martincsek wrote: > > 2) Long variable names. > > Where I work (not in Go), writing comments is frowned upon. That includes > "docblock" style comments. If a function needs to be documented, it means > the implementation is too complex and must be broken apa

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Uli Kunitz
Please have a look at golang.org/x/time/rate . This package should solve your problem. Here is an example with 10 events per second. func main() { log.SetFlags(log.Lmicroseconds) l := rate.NewLimiter(10, 1) ctx := context.Backg

[go-nuts] Go 1.18 Beta 2 is released

2022-01-31 Thread Alex Rakoczy
Hello gophers, We have just released go1.18beta2, a beta version of Go 1.18. It is cut from the master branch at the revision tagged go1.18beta2. Please try your production load tests and unit tests with the new version. Your help testing these pre-release versions is invaluable. Report any prob

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Amnon
Irrespective of the language, these sort of delays are always at the mercy of the scheduling jitter of the underlying operating system. The operating system is at liberty to preempt any application at any time, and then resume it some arbitrary time later. If you ask the OS to sleep for 1ms, th

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Robert Engels
Sorry for typos. Early morning on small phone with no coffee and old person eyes. :) > On Jan 31, 2022, at 7:13 AM, Robert Engels wrote: > >  > If you need a “guarantee” in these efforts it is much more complex. You must > likely need a real-time OS and interrupt driven code. A general purpos

Re: [go-nuts] Issues when using time.Ticker microsecond duration

2022-01-31 Thread Robert Engels
If you need a “guarantee” in these efforts it is much more complex. You must likely need a real-time OS and interrupt driven code. A general purpose language, os and hardware probably won’t cut it. This of it this way though, if you had 20 cpus to spread the work on, you only need to interrupt

Re: [go-nuts] Why Go allow function with unused arguments?

2022-01-31 Thread Kamil Ziemian
> By enforcing blanks, you'd lose the chance to name them something useful to tell the reader why they're ignored. For me this is quite straightforward: they are omitted because, they aren't needed. True question to me is: why other functions need them? But, this wouldn't be answered by looking

Re: [go-nuts] Why Go allow function with unused arguments?

2022-01-31 Thread Kamil Ziemian
Thank you kortschak for explanation. It was clear to me why abstraction by interface, require us to allow need unused parameter for methods, it didn't come to my mind that you need to pass the function with proper signature and some of this function may not need to use all parameters from signa

Re: [go-nuts] behaviour (issue) of time.Ticker microsecond duration ticks

2022-01-31 Thread fgergo
On 1/31/22, envee wrote: > Hi All, > I understand this issue has been discussed in the past, and I have seen a > few comments from Ian and Russ Cox about this topic, but I could not arrive > > at a conclusion about how I can make the time.Ticker send me ticks at > atleast close to the Ticker durat