Re: [go-nuts] Re: Semicolons in Go

2017-04-24 Thread Ian Davis
With respect, you are tilting at windmills. You replied to an 8 year old post from the design phase of the language. It's now 2017 and no-one wants to step back in time to change what has turned out to be a very successful design. You stated in your first message that you "simply won't use the

Re: [go-nuts] Recover considered harmful

2017-04-24 Thread Ian Davis
On Mon, 24 Apr 2017, at 12:06 PM, Kevin Conway wrote: > I'd say that recover() is not a problem but, instead, a symptom of > panic() being available to developers. I'd flip the title and say > panic() should be considered harmful. To quote from > https://blog.golang.org/defer-panic-and-recover :>

Re: [go-nuts] Why sort.IsSorted implemented with decrement?

2017-04-21 Thread Ian Davis
On Fri, 21 Apr 2017, at 03:31 AM, Ivan Kurnosov wrote: > @Rob, > > honestly to me they look the same: > > > func IsSorted(data Interface) bool { > n := data.Len() for i := n - 1; i > ; i-- { if data.Less(i, i-1) { >return false } } return true } > > > func IsSortedForward(data

Re: [go-nuts] Infinite loops

2017-04-18 Thread Ian Davis
On Tue, 18 Apr 2017, at 05:58 PM, Jan Mercl wrote: > On Tue, Apr 18, 2017 at 6:57 PM Frank Davidson > wrote: > > > Which loop uses the least computer resources? > > select{} Note though that select is not a loop so it will not infinitely repeat instructions.

Re: [go-nuts] Zero value of the map

2017-04-18 Thread Ian Davis
On Tue, 18 Apr 2017, at 03:20 PM, Chris Hopkins wrote: > I'm not sure what you mean by the append doesn't modify the original. > Append will use the same backing store (if there is available capacity > in it) and by definition the address of the slice in question must be > invariant across its

Re: [go-nuts] Zero value of the map

2017-04-18 Thread Ian Davis
On Tue, 18 Apr 2017, at 01:04 PM, Tad Vizbaras wrote: > > The argument could be that slices are read-only too. Just that > "append" is special and it makes zero value slices useful. > var a []int > a[0] = 1 // Fails. > // panic: runtime error: index out of range > > I am just curious

Re: [go-nuts] Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Ian Davis
What version of Go are you using. I ran your code a few times and could not reproduce on my version which is a few commits off of tip. On Tue, 4 Apr 2017, at 09:37 AM, Mukund 8kmiles wrote: > Hi, > > It is a basic index out of range but inside *math.Rand() *and not in > objects that I

Re: [go-nuts] Why were tabs chosen for indentation?

2017-03-19 Thread Ian Davis
On Sun, 19 Mar 2017, at 09:35 PM, Rob Pike wrote: > How wide should the indentation be? 2 spaces? 4? 8? Something else? > > By making the indent be a tab, you get to decide the answer to that > question and everyone will see code indented as wide (or not) as > they prefer. > > In short, this

Re: [go-nuts] golint if/else stmt and early returns

2017-03-16 Thread Ian Davis
It's saying you don't need the else clauses since you have returned in the if clause. On Thu, 16 Mar 2017, at 05:11 PM, mhhc...@gmail.com wrote: > Hi, > > golint will report > > if block ends with a return statement, so drop this else and outdent > its block (move short variable

Re: [go-nuts] Bug in regexp package?

2017-03-10 Thread Ian Davis
On Sat, 11 Mar 2017, at 12:52 AM, fishyw...@gmail.com wrote: > Playground link is at https://play.golang.org/p/6uXcuL3iyF > > I tried to match "asdf \t\n" against `\s*` and it doesn't match, > but `\s+` works. Am I holding it wrong? FindStringIndex returns nil for no match but your

Re: [go-nuts] A naive question, why not move the len and cap fields of string and slice types into the underlying types?

2017-03-03 Thread Ian Davis
Perhaps you can help the discussion by explaining the advantages you see in that change? On Fri, 3 Mar 2017, at 11:44 AM, T L wrote: > > > On Friday, March 3, 2017 at 4:27:02 PM UTC+8, Konstantin > Khomoutov wrote: >> On Thu, 2 Mar 2017 23:49:52 -0800 (PST) >> T L

Re: [go-nuts] Put the CancelFunc inside Context

2017-02-27 Thread Ian Davis
On Mon, 27 Feb 2017, at 11:39 AM, dc0d wrote: > Is there any drawbacks if we put the CancelFunc of a cancellable > context.Context inside it's values? > > Problem: I needed a cross breed of WaitGroup and Context. So a > WaitGroup and it's CancelFunc is put inside it's values and are used >

Re: [go-nuts] first try with templates

2017-02-24 Thread Ian Davis
On Fri, 24 Feb 2017, at 11:40 PM, 'simon place' via golang-nuts wrote: > https://play.golang.org/p/NGU4kstcT- > > just trying to put one var into one template and i'm failing!, see > above, i've tried the docs, googling and randomly guessing. please > someone put me out of my misery.

Re: [go-nuts] A Tour of Go: 45

2017-02-07 Thread Ian Davis
On Tue, 7 Feb 2017, at 03:36 PM, Tomi Häsä wrote: > Is it normal to get 45 in the Flow Control example? > > https://tour.golang.org/flowcontrol/1 > > package main > > import "fmt" > > func main() { > sum := 0 > for i := 0; i < 10; i++ { > sum += i > fmt.Println(i) > } >

Re: [go-nuts] Re: is it possible to speed up type assertion?

2017-02-02 Thread Ian Davis
On Thu, 2 Feb 2017, at 09:20 AM, T L wrote: > > > On Thursday, February 2, 2017 at 4:58:32 PM UTC+8, Axel Wagner wrote: >> Hi, >> >> I can not really reproduce your results. I rewrote your code to use >> the builtin benchmarking: http://sprunge.us/IfQc >> Giving, on my laptop: >> >>

Re: [go-nuts] How do you mitigate against nil pointer dereference

2017-01-13 Thread Ian Davis
On Fri, 13 Jan 2017, at 10:12 AM, mailte...@gmail.com wrote: > > Hello, > > Have been struggling with mitigating against nil pointer deference and > i would appreciate if anyone can help > > Code 1: Works file > https://play.golang.org/p/lhOh9g5R9l > > > Code 2: Error >

Re: [go-nuts] Re: invitation to gophers.slack.com

2016-12-09 Thread Ian Davis
As an aside, does anyone know if there are publicly available chatlogs from the slack channel? On Fri, Dec 9, 2016, at 02:46 PM, jorelli wrote: > ^ is this still current? I signed up sometime last week but haven't > been able to get on (._.) > > trying to get over to the chat for

Re: [go-nuts] Re: Bloom filter

2016-11-28 Thread Ian Davis
On Sat, Jan 25, 2014, at 07:17 AM, greg.z...@gmail.com wrote: > Hello, I seem to be unable to Unmarshal a bitset over size 32.. What have you tried and what errors did you encounter? If you share some code then your question will be easier to answer. -- You received this message because

Re: [go-nuts] So how exactly one does(should do) forking/pull requests in Golang world

2016-11-25 Thread Ian Davis
This is how to do it with a git repository: http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html On Fri, Nov 25, 2016, at 10:31 AM, Mariusz Gronczewski wrote: > Hi, > > So let's say there is a project, living under path > github.com/local/project. Project is

Re: [go-nuts] [ANN] RAIS: Fully open-source IIIF-compliant image server... and BONUS: the exciting story of how Go made its way into UO Libraries

2016-11-23 Thread Ian Davis
Great story and congrats on your project On Wed, Nov 23, 2016, at 06:24 PM, Jeremy Echols wrote: > *Project:* > > This one's been out a long time, but I wanted to get to a place where > it felt solid before announcing it to this list. RAIS >

Re: [go-nuts] Short Variable Declaration Question

2016-11-18 Thread Ian Davis
I think the sentence is supposed to read something like this: "The second declares out (and assigns to it as before) but only assigns a value to the existing err variable (without declaring it)" On Fri, Nov 18, 2016, at 03:02 PM, Terry McKenna wrote: > Hi Guys, > > I am reading "The Go

Re: [go-nuts] [ANN] httpsnoop, an easy way to capture http related metrics (response time, bytes written, and http status code)

2016-11-10 Thread Ian Davis
On Thu, Nov 10, 2016, at 03:21 PM, Felix Geisendörfer wrote: > >> I would think that 99+% of all type checks are to determine whether >> the supplied object provides additional functionality that can be >> used. I'm struggling to think of a situation where you would type >> check for the Flush

Re: [go-nuts] [ANN] httpsnoop, an easy way to capture http related metrics (response time, bytes written, and http status code)

2016-11-10 Thread Ian Davis
ttp.Hijacker and io.ReaderFrom. > Perhaps they determined that the go core is only using these 2 > combinations. But that’s a bit too brittle of an invariant for me to > rely on. Therefor my package does the painful thing and implements all > 16 cases … > > Cheers > Felix >

Re: [go-nuts] [ANN] httpsnoop, an easy way to capture http related metrics (response time, bytes written, and http status code)

2016-11-10 Thread Ian Davis
On Thu, Nov 10, 2016, at 02:21 PM, Felix Geisendörfer wrote: > Yes, I thought about it :). > > Did you read the "Why this package exists” section of the README? Yes but obviously not closely enough :) Kubernetes takes a hybrid approach:

Re: [go-nuts] [ANN] httpsnoop, an easy way to capture http related metrics (response time, bytes written, and http status code)

2016-11-10 Thread Ian Davis
On Thu, Nov 10, 2016, at 11:09 AM, Felix Geisendoerfer wrote: > I would love for net/http experts to take a look at the "Why this > package exists" section of the README, as well as the horrible hack > required to make things work: > >

Re: [go-nuts] Context cancellation

2016-11-02 Thread Ian Davis
On Wed, Nov 2, 2016, at 10:35 PM, Gustavo Niemeyer wrote: > Hello there, > > On Wed, Nov 2, 2016 at 11:09 AM, Ian Davis <m...@iandavis.com> wrote: >> __ >> >> On Wed, Nov 2, 2016, at 12:56 PM, 'Axel Wagner' via golang- >> nuts wrote: >>> AIUI

Re: [go-nuts] Context cancellation

2016-11-02 Thread Ian Davis
On Wed, Nov 2, 2016, at 12:56 PM, 'Axel Wagner' via golang-nuts wrote: > AIUI: A child or grandchild function is not supposed to signal that. > They can return an error and let the parent cancel, or they can create > their own child context WithCancel and cancel that. Context doesn't > replace

Re: [go-nuts] Context cancellation

2016-11-02 Thread Ian Davis
On Wed, Nov 2, 2016, at 12:12 PM, Axel Wagner wrote: > From https://godoc.org/context > >> Failing to call the CancelFunc leaks the child and its children until >> the parent is canceled or the timer fires. The go vet tool checks >> that CancelFuncs are used on all control-flow paths. > > I'm not

[go-nuts] Context cancellation

2016-11-02 Thread Ian Davis
Hi all, I'm trying to understand the idioms around cancellation of contexts. I've read the godoc and the relevant blog (https://blog.golang.org/context). Should you always call the cancelFunc of a cancellable context? Or should it only be called if the operation is terminated before successful

Re: [go-nuts] fmt.Fscan without delimeter

2016-10-19 Thread Ian Davis
On Wed, Oct 19, 2016, at 03:34 PM, Brian Picciano wrote: > Hi there! My use-case involves reading all data off of an io.Reader > and scanning it into a receiver value provided by the user of my > library. In many ways the same thing as fmt.Fscan. The difference is > that only one receiver value

Re: [go-nuts] Reasons why `go get` is entirely quiet by default

2016-10-13 Thread Ian Davis
On Thu, Oct 13, 2016, at 10:48 PM, Nyah Check wrote: > Hi everyone, > > I don't know if someone may have talked of this here. But I just wish > to find out why `go get` is entirely quiet by default? Unlike other > package managers like npm or yarn. Someone asked this on the IRC > channel today and

Re: [go-nuts] idea behind error interface and github.com/pkg/errors

2016-09-27 Thread Ian Davis
On Fri, Sep 23, 2016, at 08:03 AM, Ahmy Yulrizka wrote: > I understand that, I dont either. But what's the idea behind not > having it at the first place? Is there more to it other than make it > more simple? One possibility is that it reduces the number of allocations (for storing frame

Re: [go-nuts] Re: Ignoring UTF-8 BOM when decoding JSON

2016-09-23 Thread Ian Davis
On Fri, Sep 23, 2016, at 03:35 PM, gary.willoug...@victoriaplumb.com wrote: > Yeah, the Json decoder should handle it. Maybe post a bug report? > https://github.com/golang/go/issues This has been raised before: https://github.com/golang/go/issues/12254 The answer is to use a reader to strip the

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Ian Davis
On Tue, Sep 20, 2016, at 04:15 PM, Gabriel Adumitrachioaiei wrote: > You might be right, but I just don't realize how. Since capacity will > be 2x or 1.5x as before, reallocating the slice will not happen often. > Or do you think that this would still be worse than copying almost all > slice

Re: [go-nuts] Pop out first element of a slice.

2016-09-20 Thread Ian Davis
On Tue, Sep 20, 2016, at 03:54 PM, Gabriel Adumitrachioaiei wrote: > Well, the capacity will be reduced by one. I don't think this makes > much difference. It makes a difference for a long running service that repeatedly pushes and pops. Ian -- You received this message because you are

Re: [go-nuts] Re: How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread Ian Davis
Maybe you could investigate something like this: https://www.snellman.net/blog/archive/2016-07-27-ratas-hierarchical-timer-wheel/ Disclaimer: I've not tried that method, but I saw it recently and filed it away as potentially useful -- Ian On Thu, Aug 4, 2016, at 11:14 AM, pi wrote: > You mean

Re: [go-nuts] Understanding HTTP server latencies

2016-07-18 Thread Ian Davis
On Mon, Jul 18, 2016, at 03:13 PM, Rayland wrote: > Any thoughts on how to attack this problem? You could run the tiny example that Peter Waller wrote with the same test and share the results here. If we see the same slowdown pattern then it would eliminate a problem in your code. -- Ian --

Re: [go-nuts] What dependency management tool do you use?

2016-07-12 Thread Ian Davis
On Tue, Jul 12, 2016, at 09:23 PM, Henrik Johansson wrote: > I use gb. I like it a lot and I have had no issues. A quick question: how well do tools like go pprof work when your source code is managed by gb, outside of the GOPATH? -- Ian   -- You received this message because you are

Re: [go-nuts] log.Logger, Why is this not an interface?

2016-07-08 Thread Ian Davis
On Fri, Jul 8, 2016, at 05:29 AM, zgersh...@pivotal.io wrote: > Hey All, > > Originally asked on twitter but a more long-form medium is required to > answer this question. I've recently been working on adding logging to > a library and have been replacing what was once a custom logging > interface

Re: [go-nuts] Vendored trace package causes panic because of implicit handlers

2016-07-06 Thread Ian Davis
On Wed, Jul 6, 2016, at 12:34 PM, Jakob Borg wrote: > 2016-07-06 9:11 GMT+02:00 Peter Bourgon : > > You can't actually make this distinction. > > There should be a single vendor/ dir at the root of the repo. > > See https://github.com/zellyn/wtf2 for a demonstration. > > (And

Re: [go-nuts] Re: Singleton pattern for a client handle

2016-06-30 Thread Ian Davis
On Thu, Jun 30, 2016, at 01:10 PM, awickert wrote: > > > Am Donnerstag, 30. Juni 2016 08:29:32 UTC+2 schrieb krma...@gmail.com: >> I want a single instance of a client handle to be initialized. >> >> Is it ok to declare the instance as >> >> var client MetricsClient >> >> and then initialize

Re: [go-nuts] Re: A proposal for generic in go

2016-06-21 Thread Ian Davis
On Tue, Jun 21, 2016, at 03:17 PM, andrew.mez...@gmail.com wrote: > >>increase in cognitive load to decipher chains of type definitions. > > Sorry, but who are members of this mail lists? > This is a first time when I hear about such loads such as the > `cognitive load`. > Also I am possible

Re: [go-nuts] Re: A proposal for generic in go

2016-06-21 Thread Ian Davis
On Tue, Jun 21, 2016, at 01:45 PM, andrew.mez...@gmail.com wrote: > >>I am not saying that generics is bad, but I am questioning whether > >>generics is necessary. > > Please, do not panic. > If you worry about the following things: > - Generated code will grow when used generics > - Generated

<    1   2