[go-nuts] Best practice for client API with both context-aware and non-context-aware methods

2017-04-14 Thread Tamás Gulácsi
I vote for 2. The sql package is a bad example, as it existed before context, so it had to duplicate itself for context. -- 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 em

[go-nuts] Best practice for client API with both context-aware and non-context-aware methods

2017-04-14 Thread Jonathan Hall
I'm working on a client client API, and am accepting a `context.Context` argument as the first argument to each function. However, for ease of use, I'm also providing non-context aware versions of each method. So my API looks roughly like: FooContext(ctx context.Context, args...) Foo(a

[go-nuts] Re: NewTicker leak

2017-04-14 Thread Fabián Inostroza
Many thanks to all of you, I suspected it was related to the copy made while dereferencing the pointer but I didn't know that the runtime also stores a copy of the pointer, It is not explicitly stated in the documentation. El viernes, 14 de abril de 2017, 2:11:41 (UTC-3), Fabián Inostroza escri

Re: [go-nuts] newbie go question

2017-04-14 Thread Ian Lance Taylor
On Fri, Apr 14, 2017 at 3:34 PM, Ramachandran Gurumoorthy wrote: > > I am working on a piece of code that imports "context". All the APIs include > (foobar context.Context) variable. > > Another imported package expects "golang.org/x/net/context".Context as an > argument to one of its API. When I

[go-nuts] newbie go question

2017-04-14 Thread Ramachandran Gurumoorthy
Hello, I am working on a piece of code that imports "context". All the APIs include (foobar context.Context) variable. Another imported package expects "golang.org/x/net/context".Context as an argument to one of its API. When I try to supply foobar to the api expecting ("golang.org/x/net/cont

[go-nuts] memclr optimization and structs

2017-04-14 Thread sam.meder via golang-nuts
Hi, I've been looking into why some of our code wasn't resulting in the memclr optimization originally introduced in response to https://github.com/golang/go/issues/5373. I'm still a bit unclear on why this happens. Here is the code that triggers the issue for me: package foo import ( "

Re: [go-nuts] Re: golang tour - floating point numbers

2017-04-14 Thread Jesper Louis Andersen
If I remember correctly, you can just go wild and put in all the parenthesis you want and "go fmt" will clean it up for you wrt precedence rules On Fri, Apr 14, 2017, 14:38 Elias Naur wrote: > Your expression is (effectively) ((z*z-x)/2)*z. Use parentheses to group > the 2*z term: (z*z-x)/(2*z).

[go-nuts] golang.org/x/oauth2 AuthCodeURL

2017-04-14 Thread Manlio Perillo
Hi. The AuthCodeURL function accepts the optional opts parameters. However I can't find a reference to AuthCodeOption access_type and approval_prompt in the the RFC 6749. Where are they defined? Thanks Manlio -- You received this message because you are subscribed to the Google Groups "gol

[go-nuts] Re: NewTicker leak

2017-04-14 Thread Caleb Doxsey
Hi Fabián, The reason that this isn't working is because time.Ticker contains a runtimeTimer field: r: runtimeTimer{ when: when(d), period: int64(d), f: sendTime, arg:c, }, This corresponds with a struct defined in runtime: // Package time

[go-nuts] NewTicker leak

2017-04-14 Thread Sokolov Yura
When you dereference pointer, you creates a copy at different address. But runtime internals stores pointer to original ticker, not your copy. So, call to Stop on your copy simply does nothing. All created tickers are alive and still sending ticks. -- You received this message because you are

[go-nuts] NewTicker leak

2017-04-14 Thread Sokolov Yura
Don't do this: t.ticker = *time.NewTicker(t.period) Never, never, never dereference anything you got from standard library by pointer. (And not only from standard library). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe fro

[go-nuts] Re: Russian translation of the Tour of Go

2017-04-14 Thread Alexander Guz
I also added a pull request to add a link to this translation https://go-review.googlesource.com/c/40790/. -- 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

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-14 Thread Ian Lance Taylor
On Thu, Apr 13, 2017 at 10:45 PM, 刘桂祥 wrote: > go1.7.1 > > go run -gcflags '-N -l -m' example.go It is the -m flag that is generating the output you see. If there is some other bug, please let us know what it is. Ian > 在 2017年4月14日星期五 UTC+8下午1:18:26,Ian Lance Taylor写道: >> >> On Thu, Apr 13, 20

[go-nuts] Re: File diff based go test check

2017-04-14 Thread mhhcbon
indeed, that s great https://godoc.org/github.com/kylelemons/godebug/pretty#example-Compare I wonder if it could do side by side diff like github :s On Friday, April 14, 2017 at 1:05:38 PM UTC+2, Tamás Gulácsi wrote: > > There's kylelemons/godebug/diff -- You received this message because you

Re: [go-nuts] gosave for caller's SP

2017-04-14 Thread Ian Lance Taylor
On Fri, Apr 14, 2017 at 5:06 AM, 代君 wrote: > // void gosave(Gobuf*) > // save state in Gobuf; setjmp > TEXT runtime·gosave(SB), NOSPLIT, $0-8 > MOVQ buf+0(FP), AX // gobuf > LEAQ buf+0(FP), BX // caller's SP > MOVQ BX, gobuf_sp(AX) > MOVQ 0(SP), BX // caller's PC > MOVQ BX, gobuf_pc(AX) > MOVQ $0,

[go-nuts] Re: golang tour - floating point numbers

2017-04-14 Thread Elias Naur
Your expression is (effectively) ((z*z-x)/2)*z. Use parentheses to group the 2*z term: (z*z-x)/(2*z). - elias On Friday, April 14, 2017 at 2:30:33 PM UTC+2, ksam...@redhat.com wrote: > > Hello, > > Am a newbie to golang, and was trying myself with golang tour. > > > I was trying https://tour.

[go-nuts] golang tour - floating point numbers

2017-04-14 Thread ksampath
Hello, Am a newbie to golang, and was trying myself with golang tour. I was trying https://tour.golang.org/flowcontrol/8 and below is my code snippet for the same package main import ( "fmt" "math" ) func Sqrt(x float64) float64 { z := float64(1) for i := 0; i < 10; i++ { //z = z - (z*z-x

Re: [go-nuts] gosave for caller's SP

2017-04-14 Thread Alexander Kapshuk
On Fri, Apr 14, 2017 at 3:06 PM, 代君 wrote: > // void gosave(Gobuf*) > // save state in Gobuf; setjmp > TEXT runtime·gosave(SB), NOSPLIT, $0-8 > MOVQ buf+0(FP), AX // gobuf > LEAQ buf+0(FP), BX // caller's SP > MOVQ BX, gobuf_sp(AX) > MOVQ 0(SP), BX // caller's PC > MOVQ BX, gobuf_pc(AX) > MOVQ $0,

[go-nuts] gosave for caller's SP

2017-04-14 Thread 代君
// void gosave(Gobuf*) // save state in Gobuf; setjmp TEXT runtime·gosave(SB), NOSPLIT, $0-8 MOVQ buf+0(FP), AX // gobuf LEAQ buf+0(FP), BX // caller's SP MOVQ BX, gobuf_sp(AX) MOVQ 0(SP), BX // caller's PC MOVQ BX, gobuf_pc(AX) MOVQ $0, gobuf_ret(AX) MOVQ BP, gobuf_bp(AX) // Assert ctxt is zero. S

[go-nuts] Re: File diff based go test check

2017-04-14 Thread Tamás Gulácsi
There's kylelemons/godebug/diff -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.g

[go-nuts] Re: Vendoring nested dependencies

2017-04-14 Thread mhhcbon
I use glide. Always flatten the vendor. In go, those two types are not identical,(Main depends on Bar@v1, Foo depends on Bar@v2) No matter what you do, as they exists in different directories, they can t be equals. hth On Thursday, April 13, 2017 at 9:47:21 PM UTC+2, JB wrote: > > Our team h

[go-nuts] Re: File diff based go test check

2017-04-14 Thread mhhcbon
do you mean something like git diff ? Would like t. On Thursday, April 13, 2017 at 7:35:42 PM UTC+2, Tong Sun wrote: > > My program works on files, read from input and write to output. > > Is there any ready-made and *light *testing packages that allows me > checking whether the new output i

[go-nuts] Re: Memory use of a value

2017-04-14 Thread T L
http://www.tapirgames.com/blog/golang-summaries#cost-of-value-copy On Friday, April 14, 2017 at 12:25:01 AM UTC+8, AWildTyphlosion wrote: > > I'm trying to figure out how much memory a value. Anyone have a clue how > to? > > > -- You received this message because you are subscribed to the Googl