Re: [go-nuts] Question regarding goroutines

2017-01-24 Thread Matt Harden
In your program, the central data structure is a map of connections, and chat messages are only kept in variables. I would flip that around, and have a data structure storing the messages that you are currently attempting to distribute to the chat members, and have a goroutine or two for each

Re: [go-nuts] Question regarding goroutines

2017-01-24 Thread Matt Harden
Yes, a hang in one goroutine will spread to the rest of the goroutines, because the loop in engine() is run while holding the lock on the map. If it hangs in Write(), any other goroutine trying to run engine() would block on m.Lock(). By the way, in main() you might as well just say server()

[go-nuts] [ANN] staticcheck, gosimple and other tools have moved!

2017-01-24 Thread dominik
Hi, I have consolidated all of my Go tools in one place at honnef.co/go/tools (backed by github.com/dominikh/go-tools) This has changed a number of import paths. The command lines for the tools now live at honnef.co/go/tools/cmd – for example, staticcheck has moved from

[go-nuts] Question regarding goroutines

2017-01-24 Thread andrewinfosec
I am writing a program that is similar to a chat server. There is one server goroutine and a new goroutine is created for each client that connects. I find channels a bit difficult to reason about, so I am simply using a mutex where appropriate inside each package. An extremely simplified

[go-nuts] 2.5x higher memory usage with go1.8rc2

2017-01-24 Thread tsuna
Hi there, I have a linux/386 production binary that I compiled and deployed with go1.8rc2 and I noticed that the RSS is 2.5x of the same binary doing the same thing but compiled with go1.7.3. Anybody else noticed this already? It’s a fairly large/complex binary, so I can’t quite say what could

Re: [go-nuts] GolangRT Docs?

2017-01-24 Thread Ian Lance Taylor
On Tue, Jan 24, 2017 at 12:46 PM, josvazg wrote: > > Golang runtime has been fully translated to Go for a while now. I know I > could just read the source code directly but... > > Is there any known or recommended documentation (talk, slides, article) > about the runtime Go

[go-nuts] GolangRT Docs?

2017-01-24 Thread josvazg
Golang runtime has been fully translated to Go for a while now. I know I could just read the source code directly but... Is there any known or recommended documentation (talk, slides, article) about the runtime Go code? I am specially interested in anything that describes the Golang runtime

[go-nuts] Re: Too many field tags, how to split definitions ?

2017-01-24 Thread skatkatt
Perfect. Le mardi 24 janvier 2017 14:42:57 UTC+1, Jordan Krage a écrit : > > As of Go 1.8, this should be easy. You can now convert between two > structs which differ only in tags (1.8 release notes > ), so you can have a separate > struct definition

[go-nuts] Re: Too many field tags, how to split definitions ?

2017-01-24 Thread Jordan Krage
As of Go 1.8, this should be easy. You can now convert between two structs which differ only in tags (1.8 release notes ), so you can have a separate struct definition for each type (json, bson, gorm, strom, etc.). On Tuesday, January 24, 2017 at

[go-nuts] Too many field tags, how to split definitions ?

2017-01-24 Thread skatkatt
Hello, I'm looking for a way to split fields tags in multiple files. My application can work with different backends (mongodb / sql / storm) that could persist the same objects. Add json for the Rest API and the fields tags definitions start to be really ugly. type MyStruct struct { ID string

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread Vedran Vekic
Thanks, issue filed. https://github.com/golang/go/issues/18772 On Tuesday, January 24, 2017 at 2:13:15 PM UTC+1, Axel Wagner wrote: > > FWIW, this is the code used for formatting: > https://golang.org/src/strconv/ftoa.go#L54 > I would claim, this difference (and/or its conflict with the >

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread 'Axel Wagner' via golang-nuts
FWIW, this is the code used for formatting: https://golang.org/src/strconv/ftoa.go#L54 I would claim, this difference (and/or its conflict with the documentation) is a bug. On Tue, Jan 24, 2017 at 2:10 PM, Axel Wagner wrote: > Hm, after some more consideration,

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread 'Axel Wagner' via golang-nuts
Hm, after some more consideration, this isn't really a good explanation; %g, in conflict with the documentation, behaves differently then *both* %e and %f in this case: https://play.golang.org/p/LEVTU7r4wX On Tue, Jan 24, 2017 at 2:03 PM, Axel Wagner wrote: >

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread Vedran Vekic
I see. So why does %g produce a different number than %f? On Tuesday, January 24, 2017 at 2:03:58 PM UTC+1, Axel Wagner wrote: > > Because the default-format for floats is %g, not %f: > https://play.golang.org/p/KZBtA3ZVN3 > (documented in the fmt-godoc: https://godoc.org/fmt -- search for >

Re: [go-nuts] Why do these Printfs output different things?

2017-01-24 Thread 'Axel Wagner' via golang-nuts
Because the default-format for floats is %g, not %f: https://play.golang.org/p/KZBtA3ZVN3 (documented in the fmt-godoc: https://godoc.org/fmt -- search for "default format") On Tue, Jan 24, 2017 at 2:00 PM, Vedran Vekic wrote: > https://play.golang.org/p/-gSNqKZlst > >

[go-nuts] Why do these Printfs output different things?

2017-01-24 Thread Vedran Vekic
https://play.golang.org/p/-gSNqKZlst -- 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

Re: [go-nuts] Why is passing a pointer to a pointer in cgo dissalowed?

2017-01-24 Thread pierspowlesland
Thanks for the links Ian, very informative :) On Monday, January 23, 2017 at 5:43:56 PM UTC, Ian Lance Taylor wrote: > > On Mon, Jan 23, 2017 at 3:57 AM, > wrote: > > The doc for cgo states ... > > > > "Go code may pass a Go pointer to C provided the Go memory to

Re: [go-nuts] How to use []interface{} in generic programing

2017-01-24 Thread Konstantin Khomoutov
On Mon, 23 Jan 2017 17:47:48 -0800 (PST) hui zhang wrote: > type IReset interface { >Reset() > } > type Fight struct { >hp,mp int > } [...] > func reset1(x IReset){ >x.Reset() > } > func reset(x []IReset) { >for i := range x { > x[i].Reset() >} > }

[go-nuts] Re: How to generate generic code with generate?

2017-01-24 Thread Caleb Doxsey
I am the author... :) In some ways it doesn't matter all that much which library you use, as the purpose of these libraries is to make the generation of code easier, so they aren't runtime dependencies, and even if you decide never to use them again, you can keep the original generated code.

Re: [go-nuts] Re: How to generate generic code with generate?

2017-01-24 Thread Ignazio Di Napoli
In my opinion the best is https://github.com/cheekybits/genny. -- 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