[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread Wanton
First link in my first reply didn't use encapsulation. It gave Dog as parameter. Also not sure how golang internals work but when you encapsulate something thats probably new heap allocation. I know it's tempting to use OO patterns (classes) but golang has very powerful interface system and I th

Re: [go-nuts] Is there a reason go doesn't use the small string optomization

2017-01-31 Thread Eliot Hedeman
It may not be the most elegant solution, but you could possibly check for the high bit set on any pointer during GC. If the high bit is set, you know for sure that that pointer is not actually pointing to anything, but rather is data. Technically speaking, the top 16 bits of any pointer in x86-6

[go-nuts] Should an input validation function correct the input?

2017-01-31 Thread Tamás Gulácsi
I treat all code on pointer as it may modify the data, and use pointers sparingly. Maybe you could call it Correct instead of Verify, to be explicit. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiv

Re: [go-nuts] Looking for a SQLite statement parser

2017-01-31 Thread Philip O'Toole
Great -- thanks for the reference, I'll take a look. Philip On Tue, Jan 31, 2017 at 10:02 AM, Vasiliy Tolstov wrote: > cznic/ql have own lexer for SQL and it syntax very similar. > > 31 Янв 2017 г. 16:33 пользователь написал: > >> Hello, >> >> I am the creator of rqlite (https://github.com/rql

Re: [go-nuts] Is there a reason go doesn't use the small string optomization

2017-01-31 Thread Henrik Johansson
What makes strings harder than for example []byte? On Wed, Feb 1, 2017, 06:15 Ian Lance Taylor wrote: > On Tue, Jan 31, 2017 at 9:10 PM, Eliot Hedeman > wrote: > > I was writing up a proposal about adding the small string > > optimization(putting strings on the heap if they will fit within the

Re: [go-nuts] Is there a reason go doesn't use the small string optomization

2017-01-31 Thread Ian Lance Taylor
On Tue, Jan 31, 2017 at 9:10 PM, Eliot Hedeman wrote: > I was writing up a proposal about adding the small string > optimization(putting strings on the heap if they will fit within the > sringStruct)to the go runtime, and I realized there might be good reason why > this has not been done yet. Are

[go-nuts] Is there a reason go doesn't use the small string optomization

2017-01-31 Thread Eliot Hedeman
I was writing up a proposal about adding the small string optimization(putting strings on the heap if they will fit within the sringStruct)to the go runtime, and I realized there might be good reason why this has not been done yet. Are there any glaring reasons you can think of? Here

Re: [go-nuts] Re: How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread Sairam Kunala
If one incoming HTTP request should be sent to 5 workers async, See *solution #5* for similar problem/solution - http://rodaine.com/2015/04/async-split-io-reader-in-golang/ . A video file is required to be processed in multiple formats where io.MultiWriter is used to send all data asynchronously wh

[go-nuts] Heap fragmentation: HeapProfile reported memory vs Memstats.HeapInUse

2017-01-31 Thread Sarath Lakshman
I am observing Memstats.HeapInUse of 50GB while a heap profile reports only 24GB. I tried increasing the heapprofile rate to 1KB and still I notice the same behavior. I added an app level accounting of memory usage and that also reports close to 24GB. This makes me think that this could be memory a

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread Henry
Have you considered the possibility of splitting the prepare-and-attack method into prepare and attack respectively? Even in a OO language, I generally try to avoid a base class being dependent on its subclasses. The subclasses may depend on the base class, but not the other way around. 2-ways d

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread ojucie
My approach to mimic OOP behavior would be something like this: https://play.golang.org/p/QQvWxfOiMB It's funny how hard was to learn OOP and how easy was to unlearn it. To the present day I never had to do such gymnastic to program using Go. Not even once. -- You received this message because

Re: [go-nuts] Appending a path to an URL

2017-01-31 Thread Andy Balholm
The part being added is treated as an absolute path, because it starts with a slash, so it replaces the existing path. Andy > On Jan 31, 2017, at 2:09 PM, Manlio Perillo wrote: > > Il giorno martedì 31 gennaio 2017 18:35:02 UTC+1, Manlio Perillo ha scritto: > Thanks, I was not aware of this be

[go-nuts] Re: How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread Paweł Szczur
I read whole request body. Pack to some structure. Send to a message queue (RabbitMQ, Kafka, Google Pub/Sub). MQ services allow to configure a topic/channel to multiplex a msg to all receivers (in PubSub you would create multiple subscriptions for a given topic https://cloud.google.com/pubsub/a

Re: [go-nuts] How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread Michael Banzon
Read the content - wrap it up and start the five goroutines and pass it to them? On Tue, Jan 31, 2017 at 10:42 PM Onur Özer wrote: > No, results not sent back and yes workers rely on the content. > > On Wed, 1 Feb 2017 at 00:41, Michael Banzon wrote: > > Does the processing result get returned

[go-nuts] Re: Appending a path to an URL

2017-01-31 Thread Manlio Perillo
Il giorno martedì 31 gennaio 2017 18:35:02 UTC+1, Manlio Perillo ha scritto: > > Thanks, I was not aware of this behavior. > > The documentation says: > "Parse parses a URL in the context of the receiver. The provided URL may > be relative or absolute." > > Probably an example should be added? > >

Re: [go-nuts] How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread Onur Özer
No, results not sent back and yes workers rely on the content. On Wed, 1 Feb 2017 at 00:41, Michael Banzon wrote: > Does the processing result get returned to the client? > > Does the workers rely on the content of the request body? > > On Tue, Jan 31, 2017 at 10:38 PM oso wrote: > > Hello, I h

Re: [go-nuts] How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread Michael Banzon
Does the processing result get returned to the client? Does the workers rely on the content of the request body? On Tue, Jan 31, 2017 at 10:38 PM oso wrote: > Hello, I have 5 workers to process asynchronous HTTP requests to the > system. They all process the same HTTP request in different ways.

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread jul . semaan
Hi Wanton, Thanks for the adjustment. Henry's solution which you've ++ed seems a bit «javascript-ish» and (IMO) a bit more prone to errors with scoping. On Monday, 30 January 2017 11:01:15 UTC-5, jul.s...@gmail.com wrote: > > Hi, > > Where I work, we are currently experimenting with golang in or

[go-nuts] How can I distribute incoming HTTP request to 5 asynchronous workers?

2017-01-31 Thread oso
Hello, I have 5 workers to process asynchronous HTTP requests to the system. They all process the same HTTP request in different ways. Workers who finish their job are starting to process the HTTP request. How can I implement this system? Regards, -- You received this message because you are

Re: [go-nuts] Looking for a SQLite statement parser

2017-01-31 Thread Vasiliy Tolstov
cznic/ql have own lexer for SQL and it syntax very similar. 31 Янв 2017 г. 16:33 пользователь написал: > Hello, > > I am the creator of rqlite (https://github.com/rqlite/rqlite), a > distributed relational database built on SQLite. > > I'm looking for a lexer and parser for SQL -- specifically S

[go-nuts] Re: Appending a path to an URL

2017-01-31 Thread Manlio Perillo
Thanks, I was not aware of this behavior. The documentation says: "Parse parses a URL in the context of the receiver. The provided URL may be relative or absolute." Probably an example should be added? Manlio Il giorno martedì 31 gennaio 2017 13:07:48 UTC+1, Martin Gallagher ha scritto: > > I

[go-nuts] Should an input validation function correct the input?

2017-01-31 Thread JohnGB
In each of the handlers in an API I have, I first unmarshal the JSON request, and then validate the resulting struct. There are a few cases where I am able to pick up a correctable error in the validation code, but I'm not sure whether it's good practice to correct the error in the input data,

[go-nuts] Question on lib/pq CopyInSchema

2017-01-31 Thread Mandolyte
I have a date column which isn't fully populated. I tried to use "\N" per (1) and also just an empty string. Neither worked, both giving this error: invalid input syntax for type date Is there a way to supply null values for CopyInSchema? -- You received this message because you are subscrib

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread Wanton
Also it's probably better to use a pointer to Dog struct instead using it as value type, then it works closer to a class https://play.golang.org/p/_uS9D1i-8u . Example if you want to mutate Dog struct by adding SetAge method. On Tuesday, January 31, 2017 at 2:51:42 PM UTC+2, jul.s...@gmail.com

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread Wanton
Here is modified example of Henry's vision to show you how to access Dog struct in attack function https://play.golang.org/p/YJv1XTZWnA also another solution by using encapsulation https://play.golang.org/p/ImW9cx5fQG tiistai 31. tammikuuta 2017 14.51.42 UTC+2 jul.s...@gmail.com kirjoitti: > > H

[go-nuts] Re: About "Declaring Empty Slices" of CodeReviewComments

2017-01-31 Thread James Bardin
None of those values are escaping or being used. Your only allocation is probably the call to fmt.Fprint. This isn't something that really needs a benchmark, it should be obvious that t is nil in `var t []string`, and t is not nil in `t := []string{}`. The former doesn't allocate a slice header

[go-nuts] Looking for a SQLite statement parser

2017-01-31 Thread philip
Hello, I am the creator of rqlite (https://github.com/rqlite/rqlite), a distributed relational database built on SQLite. I'm looking for a lexer and parser for SQL -- specifically SQLite, to improve the ease-of-use of rqlite. I've thought about looking into using the C code exposed by the SQLi

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread jul . semaan
Hi, First, thanks for your ideas. One downside with Henry's idea is that the attack function cannot access potential struct attributes of the Pitbull or Dog struct (I believe, correct me if I'm wrong). Although there weren't in my example, our code will certainly have struct attributes that nee

[go-nuts] Re: Migrating from a classic OO pattern

2017-01-31 Thread Henry
Hi, One thing that I learn about Go is that it forces you to look for a specific solution to your problem, and the same solution usually cannot be applied to other similar problems. However, the same thinking can be carried over from OO to Go. The two dogs share the same preparation method an

[go-nuts] Re: About "Declaring Empty Slices" of CodeReviewComments

2017-01-31 Thread adonovan via golang-nuts
On Tuesday, 31 January 2017 00:15:40 UTC-5, Keiji Yoshida wrote: > > Hi, > > "Declaring Empty Slices" of CodeReviewComments ( > https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices > ) says as below: > > ``` > When declaring a slice, use > > var t []string > > rather than >

[go-nuts] Appending a path to an URL

2017-01-31 Thread Martin Gallagher
Is this what you want: https://play.golang.org/p/BW96Bk_sqJ -- 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 opt

[go-nuts] Appending a path to an URL

2017-01-31 Thread Martin Gallagher
Is this what you want: https://play.golang.org/p/BW96Bk_sqJ -- 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 opt

RE: [go-nuts] Is Go too strict for nesting function callings?

2017-01-31 Thread John Souvestre
Interesting! Thanks. John John Souvestre - New Orleans LA From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On Behalf Of Jonas August Sent: 2017 January 30, Mon 04:25 To: golang-nuts Subject: Re: [go-nuts] Is Go too strict for nesting function callings? O