[go-nuts] Re: totalling a column in a html template.

2016-08-25 Thread Simon Ritchie
If you follow the Model View Controller (MVC) model, you should do all of the clever stuff in your controller and just use the view to render the result. When you invoke the view, you pass a structure with it contains the data to display. The trick is to design your structure to contain all the

[go-nuts] http.Transport and too many connection problem.

2016-08-25 Thread bronze man
As I can see from the comment of http.Transport : // Transports should be reused instead of created as needed. The comment telled me that I need reuse the transports. But i am writing a rpc system that the caller can pass different dialler to make http request. It almost impossible for my rpc p

Re: [go-nuts] Syntax errors involving compound literals

2016-08-25 Thread sbkim via golang-nuts
On Wednesday, August 24, 2016 at 10:22:22 PM UTC-7, Ian Lance Taylor wrote: > > On Wed, Aug 24, 2016 at 9:21 PM, sbkim via golang-nuts > > wrote: > > Hello group, > > > > Why are the following snippets errors? > > > > https://play.golang.org/p/mgEYMNNw9h > > type S struct { > > i int > >

[go-nuts] Re: Confused about defer

2016-08-25 Thread Vasko Zdravevski
I put your code snippet in the playground for easier sharing: https://play.golang.org/p/ZvuNwjS7ZF I think the spec has the answer you're looking for regarding how named result parameters are handled during a panic. https://golang.org/ref/spec#Defer_statements Specifically the sentence: > If t

[go-nuts] Confused about defer

2016-08-25 Thread dc0d
Assuming we have this test: func TestRecover(t *testing.T) { f := func() (interface{}, error) { panic(`TEST`) } r, e := Recover(f) t.Log(r, e) } And two versions of *Recover* function. Version 1: func Recover(f func() (interface{}, error)) (interface{}, error) { var result interface{} var

Re: [go-nuts] Re: text/scanner: scan() vs peek()

2016-08-25 Thread DrGo
Thanks Sam, I managed without a token_peek(). It just leads to more verbose code with calls to scan() and switches everywhere. On Thursday, August 25, 2016 at 10:52:54 PM UTC+1, Sam Whited wrote: > > On Thu, Aug 25, 2016 at 2:09 PM, DrGo > > wrote: > > Ok! So my original post was not clear. Let

Re: [go-nuts] Re: text/scanner: scan() vs peek()

2016-08-25 Thread Sam Whited
On Thu, Aug 25, 2016 at 2:09 PM, DrGo wrote: > Ok! So my original post was not clear. Let us say you just executed scan() > twice on this string: a= x > As expected, Scan() returned scanner.Ident for a, followed by a rune > indicating the = sign. > Now, peek() will return 32 for the space wherea

Re: [go-nuts] Why does context.CancelFunc exist?

2016-08-25 Thread Sam Whited
On Thu, Aug 25, 2016 at 2:08 PM, Nate Finch wrote: > The type seems unnecessary. It doesn't actually do anything different than > a regular func(). You are correct that the behavior of the function doesn't differ, but then again behavior isn't necessarily the point of the type system. Having thi

[go-nuts] Go protocol proxy, best practices

2016-08-25 Thread Tamás Gulácsi
Check out go4.org/syncutil for Gate to limit concurrency with ease. -- 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

[go-nuts] Re: text/scanner: scan() vs peek()

2016-08-25 Thread DrGo
Ok! So my original post was not clear. Let us say you just executed scan() twice on this string: a= x As expected, Scan() returned scanner.Ident for a, followed by a rune indicating the = sign. Now, peek() will return 32 for the space whereas scan() returns scanner.Ident for the identifier x. Pe

[go-nuts] Why does context.CancelFunc exist?

2016-08-25 Thread Nate Finch
The type seems unnecessary. It doesn't actually do anything different than a regular func(). Does it just exist to give a place for common documentation for each of the methods that use it? IMO, the With* functions would be more clear if they didn't use a named type for func(), because now wh

[go-nuts] Re: text/scanner: scan() vs peek()

2016-08-25 Thread Jim Robinson
I'll admit to not understanding how your question and code example mesh, but as far as I can tell Scanner.Peek is working as it is documented in the API, it returns the rune w/o advancing: https://play.golang.org/p/DgzRcWeTRI -- You received this message because you are subscribed to the Googl

Re: [go-nuts] text/scanner: scan() vs peek()

2016-08-25 Thread Sam Whited
On Thu, Aug 25, 2016 at 12:55 PM, DrGo wrote: > Should not scanner.Peek do whatever scanner.Scan does just without advancing > the scanner? It does; scanner.Scan returns the next rune in the string and scanner.Peek returns the next rune in the string without advancing the scanner. Are you confus

[go-nuts] text/scanner: scan() vs peek()

2016-08-25 Thread DrGo
Hello, Perhaps I am misunderstanding the purpose or do not know how to optimally use this package, but the way I see it scanner.peek() is not doing what I expect it to do: return the next non-whitespace token (e.g., scanner.Ident, scanner.Int etc) without advancing the scanner. Instead it retur

[go-nuts] Re: Search for Another JSON Package

2016-08-25 Thread dc0d
Yes; I was super frustrated with big integers in JSON & your packages saved me big time! Thanks a lot! On Thursday, August 25, 2016 at 3:19:19 PM UTC+4:30, Ugorji Nwoke wrote: > > I just checked the issue you created: > https://github.com/ugorji/go/issues/168 . I see you already closed it as >

Re: [go-nuts] tbsp - Spoon-feed your table-based tests!

2016-08-25 Thread Nick Craig-Wood
On 17/08/16 16:06, Sam Boyer wrote: > OK, so this is kind of a lark, but to celebrate the new subtesting > system > in Go 1.7, I fired out a quick lib for executing table-based > tests https://github.com/sdboyer/tbsp. > > The implem

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-25 Thread Ian Lance Taylor
On Thu, Aug 25, 2016 at 12:15 AM, Cholerae Hu wrote: > Does that mean that only inlined functions will be optimized and any > functions not inlined will not be optimized ? I'm not really sure what you are asking. A function that is not inlined will not be inlined. That is sufficient to ensure t

Re: [go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-25 Thread Ian Lance Taylor
On Thu, Aug 25, 2016 at 3:09 AM, T L wrote: > > On Thursday, August 25, 2016 at 5:41:32 AM UTC+8, xiio...@gmail.com wrote: >> >> It doesn't/wouldn't seem to be any technical issue implementing methods on >> any depth of pointer type .. as demonstrated in the unsafe example linked >> from a previou

[go-nuts] Re: Panic when calling fmt.Printnl() on string (segmentation violation)

2016-08-25 Thread Dave Cheney
Whenever you suspect memory corruption, try the race detector. Can you also please post the full panic message, you cut off the important part On Friday, 26 August 2016 01:11:49 UTC+10, arb...@gmail.com wrote: > > Hello everyone, > > My application occasionally crash when processing string varia

Re: [go-nuts] Go protocol proxy, best practices

2016-08-25 Thread Zlatko Čalušić
Hello, it would be hard to give you a complete solution without knowing many more details about your application. So to comment on just one part, spawning goroutine, or two, per connection. It is absolutely THE correct way in Go. All those goroutines will be effectively mapped to system thre

[go-nuts] Re: totalling a column in a html template.

2016-08-25 Thread Val
As you may have guesses, the html/package is not designed to perform such clever calculations. It handles only the html rendering logic. You have 2 pretty good fallbacks actually : either precalculate and feed values to the template (server-side), or use javascript (client-side). Cheers Val On

[go-nuts] Go protocol proxy, best practices

2016-08-25 Thread kvratkin
Hi all, I'm looking for some good practices of concurrent programming in Go. My software works and even customer satisfied :). But I feel job doesn't done perfectly. The task was to convert some well documented but proprietary protocol to Diameter with custom dictionary. But my feelings are

[go-nuts] Re: Is it possible to create Application server in Golang?

2016-08-25 Thread madars . vitolins
There is one already, check Enduro/X ASG (https://github.com/endurox-dev/endurox, https://github.com/endurox-dev/endurox-go). You can create a modules which basically is stand alone Go binaries which does the Enduro/X organized IPC. Enduro/X monitors the processes, load balances the requests, a

[go-nuts] totalling a column in a html template.

2016-08-25 Thread Carl Ranson
HI All, been playing with using go to pull data from a few sources and serve a consolidated view as a webpage. I've got most of it going ok, but hitting a wall trying to do a totals row in an output table. anyone know if the html/template package is able to do this? the fallback is to prec

[go-nuts] Panic when calling fmt.Printnl() on string (segmentation violation)

2016-08-25 Thread arboooz
Hello everyone, My application occasionally crash when processing string variables. I can not provide you with the full example, but the code looks more or less like this: package main import "fmt" type Event struct { tokenA string tokenB string tokenC string tokenD string } func tokenLookup

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-25 Thread xiiophen
[edit] Just retracting the statement *"if you have pointers to pointers in this context you're probably doing something wrong/unnecessary*." I made earlier - which is clearly wrong on a moments thought. Sorry.. -- You received this message because you are subscribed to the Google Groups "go

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-25 Thread xiiophen
I get the original points. Though the current behaviour is in my opinion consistent with https://golang.org/ref/spec#Method_declarations "[Receiver] must be of the form T or *T (possibly using parentheses) where T is a type name" and https://golang.org/ref/spec#Method_sets I can see the case for

[go-nuts] Re: Search for Another JSON Package

2016-08-25 Thread Ugorji Nwoke
I just checked the issue you created: https://github.com/ugorji/go/issues/168 . I see you already closed it as an error in your code. You typically shouldn't have to fork the library and make changes. It is designed that you can achieve most of the customization you need by implementing an int

[go-nuts] Re: Allocating memory to consume a variable from channel in select statement

2016-08-25 Thread T L
On Wednesday, August 24, 2016 at 9:44:04 PM UTC+8, Chintan Sheth wrote: > > I am using select statement to dispatch work coming from multiple > goroutines, the variables used to consume the channel are allocated > manually as I am recycling those > > > for { > a := getA() > b := getB() > sel

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-25 Thread T L
On Thursday, August 25, 2016 at 5:41:32 AM UTC+8, xiio...@gmail.com wrote: > > It doesn't/wouldn't seem to be any technical issue implementing methods on > any depth of pointer type .. as demonstrated in the unsafe example linked > from a previous related discussion (ie > https://groups.google

[go-nuts] Re: Why a **T value can't call methods of *T and T if a *T value can call methods of T?

2016-08-25 Thread T L
On Thursday, August 25, 2016 at 5:41:32 AM UTC+8, xiio...@gmail.com wrote: > > It doesn't/wouldn't seem to be any technical issue implementing methods on > any depth of pointer type .. as demonstrated in the unsafe example linked > from a previous related discussion (ie > https://groups.google

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-25 Thread Dave Cheney
Not really. Runtime.KeepAlive is special, it'll continue to be special in the future. -- 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...@go

Re: [go-nuts] In the future, how to keep runtime.KeepAlive from dead code elimination?

2016-08-25 Thread Cholerae Hu
Does that mean that only inlined functions will be optimized and any functions not inlined will not be optimized ? 在 2016年8月25日星期四 UTC+8上午11:55:12,Ian Lance Taylor写道: > > On Wed, Aug 24, 2016 at 7:06 PM, Cholerae Hu > wrote: > > > > I've read the source of package runtime, and found that > r