[go-nuts] Best practice for client API with both context-aware and non-context-aware methods
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 email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Best practice for client API with both context-aware and non-context-aware methods
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(args...) where Foo(args...) just calls FooContext(context.Background(), args...). Multiply this times about 25 methods across a few different types, and I have a very cluttered package (and godoc). I borrowed this approach from the `sql` package. But the sql package has about half as many methods, so it seems less cluttered. It also has to retain backward compatibility with context-unaware code. Is there anything like a "best practice" in this area, given that (unlike the `sql` package) I have no backward compatibility to maintain? Some options I've considered: 1. Keep things as they are. 2. Only expose the 'Context' versions of my methods (and drop the 'Context' suffix) 3. For each type, add a single `Background()` method, which returns a clone type, that uses a background context. So `client.Foo()` becomes `client.Background().Foo()`. This doesn't reduce clutter, but it helps to organize it on the godoc page, by grouping all the Context-aware methods together, and the unaware together. I think I'm leaning toward #2. I imagine a fair number of Go newbies will find the context argument to be "strange", but I hope documentation will fix that. Are there other alternatives I should consider? Much thanks, Jonathan -- 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.google.com/d/optout.
[go-nuts] Re: NewTicker leak
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 escribió: > > Hi, > > I'm writing and application where I need to check for some condition and > do something every 'x' < 'y' seconds. If the condition is not true after > 'y' seconds I do something. Every time the condition checked every 'x' > seconds is true I have to reset the 'y' timeout. > > I wrote a test application based on code found in > https://medium.com/@arpith/resetting-a-ticker-in-go-63858a2c17ec > package main > > import "time" > > // Ticker asdf > type Ticker struct { > period time.Duration > ticker time.Ticker > } > > func createTicker(period time.Duration) *Ticker { > return &Ticker{period, *time.NewTicker(period)} > } > > func (t *Ticker) resetTicker() { > t.ticker.Stop() > t.ticker = *time.NewTicker(t.period) > } > > type timers struct { > ticker1 Ticker > ticker2 Ticker > donechan bool > } > > func (t *timers) work() { > condition := true > count := 0 > for { > select { > case <-t.ticker1.ticker.C: > if condition { > if count >= 5 { > count = 0 > condition = false > } else { > t.ticker2.resetTicker() > count++ > } > } > case <-t.ticker2.ticker.C: > if count >= 2 { > count = 0 > condition = true > } > count++ > case <-t.done: > return > } > } > } > > func createPeriodicTask() *timers { > ticker1 := createTicker(time.Duration(5) * time.Second) > ticker2 := createTicker(time.Duration(1) * time.Minute) > quit := make(chan bool) > > timer := timers{*ticker1, *ticker2, quit} > return &timer > } > > func main() { > timersArray := make([]*timers, 1000) > > for i := range timersArray { > timer := createPeriodicTask() > timersArray[i] = timer > go timer.work() > } > > //m := runtime.MemStats{} > for { > for i := range timersArray { > select { > case <-timersArray[i].done: > break > default: > time.Sleep(time.Duration(2000) * time.Millisecond) > //fmt.Println("Numero de goroutines existentes: ", > runtime.NumGoroutine()) > //runtime.ReadMemStats(&m) > //fmt.Printf("%+v\n", m) > } > } > } > } > > > If I run this program for many hours the memory usage of the process > steadily increases. > > I changed the Ticker struct definition to use pointers to the > time.newTicker and the problem is gone but I don't understand what was > wrong with the first version, could somebody give me a hint? > -- 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.google.com/d/optout.
Re: [go-nuts] newbie go question
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 try to supply foobar to the api > expecting ("golang.org/x/net/context".Context), I get a compiler error. > > cannot use &ctxt (type *"context".Context) as type > *"golang.org/x/net/context".Context in argument to > "gopkg.in/spacemonkeygo/monitor.v1/trace".Trace: > *"golang.org/x/net/context".Context is pointer to interface, not interface > > Question: Is there a way to cast context.Context to > "golang.org/x/net/context".Context? In 1.9, type aliases will address this problem. In 1.8 and earlier, no, there is no way. That said, it's odd to pass a *context.Context. A context.Context is an interface type, and can normally be passed by value. If the API genuinely does require a pointer, then you can workaround the problem by writing something along the lines of import oldcontext "golang.org/x/net/context" var oldctxt oldcontext.Context = ctxt trace.F(&oldctxt) ctxt = oldctxt Since the two different Context types are both interface types with the same methods, they are assignment-compatible. Ian -- 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.google.com/d/optout.
[go-nuts] newbie go question
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/context".Context), I get a compiler error. *cannot use &ctxt (type *"context".Context) as type *"golang.org/x/net/context".Context in argument to "gopkg.in/spacemonkeygo/monitor.v1/trace".Trace:* * *"golang.org/x/net/context".Context is pointer to interface, not interface* Question: Is there a way to cast context.Context to "golang.org/x/net/context".Context? Thank you, Ram. -- 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.google.com/d/optout.
[go-nuts] memclr optimization and structs
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 ( "testing" ) type Foo struct { H string A int64 B int64 C int64 } func BenchmarkClear4(b *testing.B) { b.RunParallel(func(pb *testing.PB) { testFoo := make([]Foo, 100) for pb.Next() { for i := range testFoo { testFoo[i] = Foo{} } } }) } For me (go 1.8) the above snippet results in asm that doesn't make use of memclr. On the other hand, when I comment out field C in the struct above then the code does make use of the optimization. Similarly, when I change the first field from string to int64, it also works. Is this expected? If so, is there some documentation for the criteria for the optimization? /Sam -- 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.google.com/d/optout.
Re: [go-nuts] Re: golang tour - floating point numbers
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). > > - 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.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)/2*z -- this does not work why ??? >> z = z - (float64(z*z)-float64(x))/float64(2*z) >> } >> return float64(z) >> } >> >> func main() { >> fmt.Printf("Ans: %0.2f \n", Sqrt(4)) >> fmt.Printf("math.Sqrt: %0.2f", math.Sqrt(4)) >> } >> >> >> I assume that all data is handled as float64 only, if you see the >> commented codes not seem to work especially for simple Sqrt(4) i get an >> answer of 1.76 instead of 2 ;) .. but after i did the casting to >> float64(..) it seem to work right.. >> >> I am not able to understand why .. >> >> any thoughts ? >> > -- > 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.google.com/d/optout. > -- 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.google.com/d/optout.
[go-nuts] golang.org/x/oauth2 AuthCodeURL
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 "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.google.com/d/optout.
[go-nuts] Re: NewTicker leak
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 knows the layout of this structure. // If this struct changes, adjust ../time/sleep.go:/runtimeTimer. // For GOOS=nacl, package syscall knows the layout of this structure. // If this struct changes, adjust ../syscall/net_nacl.go:/runtimeTimer. type timer struct { i int // heap index // Timer wakes up at when, and then at when+period, ... (period > 0 only) // each time calling f(arg, now) in the timer goroutine, so f must be // a well-behaved function and not block. when int64 period int64 f func(interface{}, uintptr) arginterface{} sequintptr } Notice that one of the fields is the heap index. When the runtime timer is initialized that heap index is set like this: t.i = len(timers.t) And, crucially, it's updated anytime timers are added or removed: if i != last { timers.t[i] = timers.t[last] timers.t[i].i = i } When you dereferenced the Ticker pointer, you made a copy of the this struct. This meant that those updates to the heap index weren't happening to your copy, but only the original struct. When you then tried to remove the timer, it had the wrong index. - Caleb On Friday, April 14, 2017 at 1:11:41 AM UTC-4, Fabián Inostroza wrote: > > Hi, > > I'm writing and application where I need to check for some condition and > do something every 'x' < 'y' seconds. If the condition is not true after > 'y' seconds I do something. Every time the condition checked every 'x' > seconds is true I have to reset the 'y' timeout. > > I wrote a test application based on code found in > https://medium.com/@arpith/resetting-a-ticker-in-go-63858a2c17ec > package main > > import "time" > > // Ticker asdf > type Ticker struct { > period time.Duration > ticker time.Ticker > } > > func createTicker(period time.Duration) *Ticker { > return &Ticker{period, *time.NewTicker(period)} > } > > func (t *Ticker) resetTicker() { > t.ticker.Stop() > t.ticker = *time.NewTicker(t.period) > } > > type timers struct { > ticker1 Ticker > ticker2 Ticker > donechan bool > } > > func (t *timers) work() { > condition := true > count := 0 > for { > select { > case <-t.ticker1.ticker.C: > if condition { > if count >= 5 { > count = 0 > condition = false > } else { > t.ticker2.resetTicker() > count++ > } > } > case <-t.ticker2.ticker.C: > if count >= 2 { > count = 0 > condition = true > } > count++ > case <-t.done: > return > } > } > } > > func createPeriodicTask() *timers { > ticker1 := createTicker(time.Duration(5) * time.Second) > ticker2 := createTicker(time.Duration(1) * time.Minute) > quit := make(chan bool) > > timer := timers{*ticker1, *ticker2, quit} > return &timer > } > > func main() { > timersArray := make([]*timers, 1000) > > for i := range timersArray { > timer := createPeriodicTask() > timersArray[i] = timer > go timer.work() > } > > //m := runtime.MemStats{} > for { > for i := range timersArray { > select { > case <-timersArray[i].done: > break > default: > time.Sleep(time.Duration(2000) * time.Millisecond) > //fmt.Println("Numero de goroutines existentes: ", > runtime.NumGoroutine()) > //runtime.ReadMemStats(&m) > //fmt.Printf("%+v\n", m) > } > } > } > } > > > If I run this program for many hours the memory usage of the process > steadily increases. > > I changed the Ticker struct definition to use pointers to the > time.newTicker and the problem is gone but I don't understand what was > wrong with the first version, could somebody give me a hint? > -- 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.google.com/d/optout.
[go-nuts] NewTicker leak
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 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.google.com/d/optout.
[go-nuts] NewTicker leak
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 from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Russian translation of the Tour of Go
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-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] go build -gcflags '-N -l' don't work
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, 2017 at 8:33 PM, 刘桂祥 wrote: >> > // example.go >> > package main >> > >> > >> > import "runtime" >> > >> > >> > type S struct{} >> > >> > >> > func main() { >> > var stats runtime.MemStats >> > >> > >> > runtime.ReadMemStats(&stats) >> > println(stats.Mallocs) >> > var x S >> > runtime.ReadMemStats(&stats) >> > println(stats.Mallocs) >> > _ = *ref(x) >> > runtime.ReadMemStats(&stats) >> > println(stats.Mallocs) >> > } >> > >> > >> > func ref(z S) *S { >> > return &z >> > } >> > >> > go build -gcflags '-N -l' example.go && ./example >> > or >> > go run -gcflags '-N -l' example.go >> > >> > results: >> > ./example.go:21: &z escapes to heap >> > ./example.go:20: moved to heap: z >> > ./example.go:10: main &stats does not escape >> > ./example.go:13: main &stats does not escape >> > ./example.go:16: main &stats does not escape >> > 61 >> > 61 >> > 61 >> >> That looks like the output from -gcflags="-m -l". Are you really sure >> you typed -N? What version of Go are you using? >> >> Ian > > -- > 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.google.com/d/optout. -- 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.google.com/d/optout.
[go-nuts] Re: File diff based go test check
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 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.google.com/d/optout.
Re: [go-nuts] gosave for caller's SP
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, gobuf_ret(AX) > MOVQ BP, gobuf_bp(AX) > // Assert ctxt is zero. See func save. > MOVQ gobuf_ctxt(AX), BX > TESTQ BX, BX > JZ 2(PC) > CALL runtime·badctxt(SB) > get_tls(CX) > MOVQ g(CX), BX > MOVQ BX, gobuf_g(AX) > RET > > why dose these code(`LEAQ buf+0(FP), BX // caller's SP`) can get caller's > SP? (these code are from golang 1.8 asm_amd64.s) The caller's stack pointer is simply the stack pointer before calling into this function. The Go assembler arranges for the pseudo-register FP to point to the function's arguments. 0(FP) is the location of the first argument, and is therefore the stack pointer as seen by the caller. See the description of FP at https://golang.org/doc/asm. Ian -- 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.google.com/d/optout.
[go-nuts] Re: golang tour - floating point numbers
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.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)/2*z -- this does not work why ??? > z = z - (float64(z*z)-float64(x))/float64(2*z) > } > return float64(z) > } > > func main() { > fmt.Printf("Ans: %0.2f \n", Sqrt(4)) > fmt.Printf("math.Sqrt: %0.2f", math.Sqrt(4)) > } > > > I assume that all data is handled as float64 only, if you see the > commented codes not seem to work especially for simple Sqrt(4) i get an > answer of 1.76 instead of 2 ;) .. but after i did the casting to > float64(..) it seem to work right.. > > I am not able to understand why .. > > any thoughts ? > -- 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.google.com/d/optout.
[go-nuts] golang tour - floating point numbers
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)/2*z -- this does not work why ??? z = z - (float64(z*z)-float64(x))/float64(2*z) } return float64(z) } func main() { fmt.Printf("Ans: %0.2f \n", Sqrt(4)) fmt.Printf("math.Sqrt: %0.2f", math.Sqrt(4)) } I assume that all data is handled as float64 only, if you see the commented codes not seem to work especially for simple Sqrt(4) i get an answer of 1.76 instead of 2 ;) .. but after i did the casting to float64(..) it seem to work right.. I am not able to understand why .. any thoughts ? -- 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.google.com/d/optout.
Re: [go-nuts] gosave for caller's SP
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, gobuf_ret(AX) > MOVQ BP, gobuf_bp(AX) > // Assert ctxt is zero. See func save. > MOVQ gobuf_ctxt(AX), BX > TESTQ BX, BX > JZ 2(PC) > CALL runtime·badctxt(SB) > get_tls(CX) > MOVQ g(CX), BX > MOVQ BX, gobuf_g(AX) > RET > > why dose these code(`LEAQ buf+0(FP), BX // caller's SP`) can get caller's > SP? (these code are from golang 1.8 asm_amd64.s) > > > > and where could I find some description for golang's assembler instruction > set. > > -- > 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.google.com/d/optout. https://golang.org/doc/asm https://talks.golang.org/2016/asm.slide#1 -- 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.google.com/d/optout.
[go-nuts] gosave for caller's SP
// 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. See func save. MOVQ gobuf_ctxt(AX), BX TESTQ BX, BX JZ 2(PC) CALL runtime·badctxt(SB) get_tls(CX) MOVQ g(CX), BX MOVQ BX, gobuf_g(AX) RET why dose these code(`LEAQ buf+0(FP), BX // caller's SP`) can get caller's SP? (these code are from golang 1.8 asm_amd64.s) and where could I find some description for golang's assembler instruction set. -- 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.google.com/d/optout.
[go-nuts] Re: File diff based go test check
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.google.com/d/optout.
[go-nuts] Re: Vendoring nested dependencies
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 has run into some complicated issues regarding vendoring. The > simplest way to explain it is with an illustration. > > We have three separate repositories; Main, Foo and Bar. > > Main vendors Bar > Main vendors Foo > Foo vendors Bar > > When trying to build this code, compile errors like this arise: > > ./main.go:12: cannot use Bar.Method() (type *"Main/vendor/Foo/vendor/Bar".T) > as type *"Main/vendor/Bar".T in assignment > > > Flattening the vendor folder structure so that all vendored dependencies > (nested or not) all resolve in the same place will solve this, but if there > are actually different versions of Foo (Main depends on Bar@v1, Foo > depends on Bar@v2) then this becomes problematic once again. > > We use govendor as our dependency management tool. > > How can we deal with this issue properly? > -- 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.google.com/d/optout.
[go-nuts] Re: File diff based go test check
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 is the same as before? > > Thanks > > > -- 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.google.com/d/optout.
[go-nuts] Re: Memory use of a value
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 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.google.com/d/optout.