Re: [go-nuts] Program gets "stuck" after saving a string of certain length

2017-06-27 Thread Abhijeet Rastogi
You should use gometalinter to check your code for warnings/suggestions. That will help you write better code and you’ll know where your code is erroring out. I use vim-go to have this integration in my editor itself. I ran your code against gometalinter and this is what I have. ➜ $?=0 /tmp/temp

[go-nuts] Re: Program gets "stuck" after saving a string of certain length

2017-06-27 Thread Tamás Gulácsi
Please, check all the returned errors! -- 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://g

Re: [go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread keith . randall
This looks like it is all due to the extra zeroing required for the Copy test. CloneWithAppend does not need to zero the newly allocated slice before copying the contents of x into it. CloneWithCopy does. Benchmark_CloneWithAppend-4 3000480247 ns/op Benchmark_CloneWithCopy-410

Re: [go-nuts] reflect.StructOf oddity

2017-06-27 Thread Jon Bodner
https://github.com/golang/go/issues/20824 On Tuesday, June 27, 2017 at 10:34:19 PM UTC-4, Jon Bodner wrote: > > Hi Ian, > > I'll file the bug report. Thanks for explaining how wrapper methods work. > I have a second test case with a pointer (and a successful attempt to > multiply a string by 2)

Re: [go-nuts] reflect.StructOf oddity

2017-06-27 Thread Jon Bodner
Hi Ian, I'll file the bug report. Thanks for explaining how wrapper methods work. I have a second test case with a pointer (and a successful attempt to multiply a string by 2): https://play.golang.org/p/Dq9Y8DAkvA Thanks, Jon On Tuesday, June 27, 2017 at 5:01:05 PM UTC-4, Ian Lance Taylor wr

Re: [go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
Hit send too early... Your benchmarks do show that something is strange hen comparing the make (memclr) and copy (memory copy) cases. Out of my element here :) On Jun 27, 2017 7:01 PM, "Kevin Malachowski" wrote: > But memclr+copy is slower than just copy, right? > > On Jun 27, 2017 6:53 PM, "T L

Re: [go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
But memclr+copy is slower than just copy, right? On Jun 27, 2017 6:53 PM, "T L" wrote: > > > On Tuesday, June 27, 2017 at 8:55:48 PM UTC-4, Kevin Malachowski wrote: >> >> It's best to compare the assembly, but my guess: 'make' has to zero out >> the memory, whereas allocation using append does n

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread T L
On Tuesday, June 27, 2017 at 8:55:48 PM UTC-4, Kevin Malachowski wrote: > > It's best to compare the assembly, but my guess: 'make' has to zero out > the memory, whereas allocation using append does not. allocation using append will copy each element, which should be slower than memclr. --

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread T L
On Tuesday, June 27, 2017 at 6:20:42 PM UTC-4, peterGo wrote: > > T L, > > For equivalency, why did you write, > > func Benchmark_CloneWithCopy(b *testing.B) { > for i := 0; i < b.N; i++ { > t := make([]Element, N) > copy(t, x) > y = t > } > } > > instaed of > > fu

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread Kevin Malachowski
It's best to compare the assembly, but my guess: 'make' has to zero out the memory, whereas allocation using append does not. -- 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

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread peterGo
T L, For equivalency, why did you write, func Benchmark_CloneWithCopy(b *testing.B) { for i := 0; i < b.N; i++ { t := make([]Element, N) copy(t, x) y = t } } instaed of func Benchmark_CloneWithCopy(b *testing.B) { for i := 0; i < b.N; i++ { y = make([

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread peterGo
T L, Why didn't you show us the output from $ go tool compile -m -m clone_test.go ? Peter On Tuesday, June 27, 2017 at 11:33:30 AM UTC-4, T L wrote: > > Ok, I think there are two reasons why the copy version is slower: > 1. the copy version initializes each element twice actutally. > 2. alloc

Re: [go-nuts] reflect.StructOf oddity

2017-06-27 Thread Ian Lance Taylor
On Tue, Jun 27, 2017 at 11:06 AM, Jon Bodner wrote: > > I was writing up an example to demonstrate that embedded fields in a > dynamically generated struct don't delegate. Except that I somehow made one > that did: > > https://play.golang.org/p/TWApy-JibG > > What's extra-odd is that the behavior

[go-nuts] Re: Program gets "stuck" after saving a string of certain length

2017-06-27 Thread ken . kofi . acquah
EDIT: This problem was solved by the classic shutting off my computer and turning it back on, but does anyone know why this mightve happened? On Tuesday, June 27, 2017 at 12:27:06 PM UTC-7, Kenneth Acquah wrote: > > I am running the following program: > > package main > > import ( > "math/rand"

[go-nuts] Program gets "stuck" after saving a string of certain length

2017-06-27 Thread ken . kofi . acquah
I am running the following program: package main import ( "math/rand" "os" "gopkg.in/cheggaaa/pb.v1" ) func random(min, max int) int { return rand.Intn(max - min) + min } var data = "" const TestDataCount = 2 func main() { bar := pb.StartNew(TestDataCount) f,_ := os.Create("HelloWorld.txt") f

[go-nuts] reflect.StructOf oddity

2017-06-27 Thread Jon Bodner
Hi all, I was writing up an example to demonstrate that embedded fields in a dynamically generated struct don't delegate. Except that I somehow made one that did: https://play.golang.org/p/TWApy-JibG What's extra-odd is that the behavior is completely wrong; it's doubling off of the wrong fie

[go-nuts] Re: x/mobile: using syscalls on iOS

2017-06-27 Thread Elias Naur
I believe this is https://github.com/golang/go/issues/17490 . I don't know if any apps have been rejected because of the use of raw syscalls. I know of several apps that were accepted. - elias On Tuesday, June 27, 2017 at 2:44:59 PM UTC+2, petra...@minus5.hr wrote: > > Hello, > > > While on WW

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread T L
Ok, I think there are two reasons why the copy version is slower: 1. the copy version initializes each element twice actutally. 2. alloc a new slice by using make is slow than by using append. But why this? package main import ( "testing" ) const N = 1024 * 1024 // number of elements type E

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread T L
Aha, maybe the benchmark has flaw. Here is another version: package main import ( "testing" ) const N = 1024 * 1024 // number of elements type Element int64 var x = make([]Element, N) var y []Element func Benchmark_CloneWithAppend(b *testing.B) { for i := 0; i < b.N; i++ { y =

Re: [go-nuts] Re: Getting information regarding what's at a memory location in race detector output?

2017-06-27 Thread Dave Cheney
Actually I think you're right. This does look like a memory address. Anyway, knowing the address isn't much use, especially if it's on the heap. On Wed, Jun 28, 2017 at 12:55 AM, Abhijeet Rastogi wrote: > Hi Dave, > > Thanks for the response. I assumed that this was the memory location of > varia

[go-nuts] Why copy is much slower than append when clone a slice?

2017-06-27 Thread T L
package main import ( "testing" ) const N = 1024 * 1024 // number of elements type Element int64 var x = make([]Element, N) var y []Element func Benchmark_CloneWithAppend(b *testing.B) { for i := 0; i < b.N; i++ { y = append([]Element(nil), x...) } } func Benchmark_CloneWi

[go-nuts] Re: Benchmarks of append vs copy

2017-06-27 Thread T L
The benchmarks have flaws. The modifications to local variables in a benchmark should be reflected to outside of the benchmark, otherwise compiler may make some optimizations for the benchmarked code. On Wednesday, January 28, 2015 at 2:30:48 AM UTC+8, Michael Tiller wrote: > > I don't really pr

Re: [go-nuts] Re: Getting information regarding what's at a memory location in race detector output?

2017-06-27 Thread Abhijeet Rastogi
Hi Dave, Thanks for the response. I assumed that this was the memory location of variable and not the program counter. Cheers On Tue, Jun 27, 2017 at 4:48 PM, Dave Cheney wrote: > > > On Tuesday, 27 June 2017 20:53:57 UTC+10, Abhijeet Rastogi wrote: >> >> Hi everyone, >> >> Let's suppose I hav

[go-nuts] Re: Linking problems on Visual Studio 2015

2017-06-27 Thread ogimenezb
Were you able to solve it? On Thursday, March 16, 2017 at 5:35:13 PM UTC+1, Robert Bielik wrote: > > Hi all, > > I have a project where I want to use grpc-gateway (written in Go) to > expose a gRPC endpoint via REST. I've managed to get it to work with > gateway parts compiled with Go into a sep

[go-nuts] x/mobile: using syscalls on iOS

2017-06-27 Thread petra . almic
Hello, While on WWDC, an Apple engineer who works on compilers and build process in Xcode told me that there is a problem with frameworks made with gomobile. So, Go is using syscalls on iOS, and that is not allowed because it's private API and Apple doesn't guarantee ABI stability on iOS upda

Re: [go-nuts] Goroutine error when running on load test.

2017-06-27 Thread Nupur Bansal
Thanks..resolved this issue. On Tuesday, June 27, 2017 at 4:13:28 PM UTC+5:30, Dave Cheney wrote: > > That's what globals do. > > On Tuesday, 27 June 2017 20:32:12 UTC+10, Nupur Bansal wrote: >> >> It seems my global variables are being accessed concurrently by >> goroutines and it is causing rac

[go-nuts] Re: Getting information regarding what's at a memory location in race detector output?

2017-06-27 Thread Dave Cheney
On Tuesday, 27 June 2017 20:53:57 UTC+10, Abhijeet Rastogi wrote: > > Hi everyone, > > Let's suppose I have this race detector output:- > > == > > WARNING: DATA RACE > > Write at 0x00c4202fc000 by goroutine 24: > > main.(*Host).refreshIP.func2() > > /path/to/code/host.go:

[go-nuts] Getting information regarding what's at a memory location in race detector output?

2017-06-27 Thread Dave Cheney
Which version of Go are you using? -- 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://group

[go-nuts] Getting information regarding what's at a memory location in race detector output?

2017-06-27 Thread Abhijeet Rastogi
Hi everyone, Let's suppose I have this race detector output:- == WARNING: DATA RACE Write at 0x00c4202fc000 by goroutine 24: main.(*Host).refreshIP.func2() /path/to/code/host.go:195 +0xa0 Previous write at 0x00c4202fc000 by goroutine 21: main.(*Host).refreshIP.fu

[go-nuts] Re: What is your favorite Go feature?

2017-06-27 Thread ojucie
The static linked executable is a pretty good feature, for sure. Go has a bunch of ideas that are implemented with great care. My personal favorite is Go support for CSP, or what we use to call "channels and goroutines". The other day I decided to change a little program that consumes a lot of

Re: [go-nuts] Goroutine error when running on load test.

2017-06-27 Thread Dave Cheney
That's what globals do. On Tuesday, 27 June 2017 20:32:12 UTC+10, Nupur Bansal wrote: > > It seems my global variables are being accessed concurrently by goroutines > and it is causing race condition. > > On Tuesday, June 27, 2017 at 3:05:03 PM UTC+5:30, Dave Cheney wrote: >> >> You have at least

Re: [go-nuts] Goroutine error when running on load test.

2017-06-27 Thread Nupur Bansal
It seems my global variables are being accessed concurrently by goroutines and it is causing race condition. On Tuesday, June 27, 2017 at 3:05:03 PM UTC+5:30, Dave Cheney wrote: > > You have at least one data race in your program. > > https://golang.org/doc/go1.6#runtime > https://blog.golang.org

[go-nuts] Re: What is your favorite Go feature?

2017-06-27 Thread ojucie
Thanks! On Monday, June 26, 2017 at 4:55:27 PM UTC-3, M P r a d e s wrote: > > There was already an extensive survey published this year asking that kind > of question : > > https://blog.golang.org/survey2016-results > > You'll already get more data than you want here. > -- You received this m

Re: [go-nuts] Goroutine error when running on load test.

2017-06-27 Thread Dave Cheney
You have at least one data race in your program. https://golang.org/doc/go1.6#runtime https://blog.golang.org/race-detector https://golang.org/doc/articles/race_detector.html Looking at the panic message it looks like your findSupplierOrBuyer method is updating a map that is part of a User's Das

Re: [go-nuts] Goroutine error when running on load test.

2017-06-27 Thread Nupur Bansal
Top part says: fatal error: concurrent map writes goroutine 23673 [running]: runtime.throw(0x95fc7f, 0x15) /usr/lib/go/src/runtime/panic.go:566 +0x95 fp=0xc420482708 sp=0xc4204826e8 runtime.mapassign1(0x8cb4c0, 0xc4200e8e10, 0xc420482a88, 0xc420482a68) /usr/lib/go/src/runtime/hashmap.go:

[go-nuts] Re: How do you create and use shared libraries in Go?

2017-06-27 Thread Igor Maznitsa
Go also allows to produce plugins (DLL) which can be loaded dynamically, it also one of ways to share compiled libraries and if I want share some library on sources level between several modules and

[go-nuts] Re: What is your favorite Go feature?

2017-06-27 Thread Igor Maznitsa
I very love its possibility to produce a static linked executable file which can be just sent to customer without words "you should download special SDK with 150 Mb size to start my 2 Mb file" -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To