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

2016-08-26 Thread Cholerae Hu
I see, thanks. 在 2016年8月25日星期四 UTC+8上午11:42:10,Cholerae Hu写道: > > Hi all, > > I've read the source of package runtime, and found that runtime.KeepAlive > is an empty function. If go compiler can do dead code elimination in the > future, how to protect runtime.KeepAlive from being optimized? >

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 9:46 PM, T L wrote: > >> "You are suggesting that there is an extra rule to forbids converting []T1 >> to > []T2 when T1 and T2 have the same underlying representation." > > No. I understand []T1 can't be converted to []T2 when T1 and T2 have >

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 12:28:16 PM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 8:52 PM, T L > wrote: > > > > On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor > wrote: > >> > >> On Fri, Aug 26, 2016 at 8:17 PM, T L

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 8:52 PM, T L wrote: > > On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor wrote: >> >> On Fri, Aug 26, 2016 at 8:17 PM, T L wrote: >> > >> > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: >> >> >> >>

[go-nuts] Using go test capabilities a as testing framework for other system.

2016-08-26 Thread erich . cm
Hi everyone, Let's say that I have a system (a C/C++ system with different binaries) and currently we use pytest to make functional testing in that system, execute commands with different arguments, retrieving the stdout, stderr and retcode for every execution. Pytest now gives us a good

[go-nuts] Re: Why can't you take the address of a function's return value?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 11:34:05 AM UTC+8, T L wrote: > > > > On Tuesday, August 23, 2016 at 1:25:03 AM UTC+8, con...@superhuman.com > wrote: >> >> Hey All, >> >> I've been using a typedef of >> >> type MaybeTimestamp *int64 >> >> so we can JSON encode timestamps correctly, see >>

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 11:40:20 AM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 8:17 PM, T L > wrote: > > > > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > >> > >> Hi, > >> > >> Generally speaking, you may find it a bit of

Re: [go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 8:17 PM, T L wrote: > > On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: >> >> Hi, >> >> Generally speaking, you may find it a bit of struggling if you are trying >> to write Go code in an attempt to emulate *how* other languages can do,

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > > Hi, > > Generally speaking, you may find it a bit of struggling if you are trying > to write Go code in an attempt to emulate *how* other languages can do, or > to argue with the compiler about how a fresh learner would come to

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 9:06:00 AM UTC+8, mura wrote: > > Hi, > > Generally speaking, you may find it a bit of struggling if you are trying > to write Go code in an attempt to emulate *how* other languages can do, or > to argue with the compiler about how a fresh learner would come to

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 2:12:55 AM UTC+8, Ian Lance Taylor wrote: > > On Fri, Aug 26, 2016 at 10:51 AM, T L > wrote: > > > > On Saturday, August 27, 2016 at 1:43:03 AM UTC+8, Axel Wagner wrote: > >> > >> The effort is putting a special case into the language for

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

2016-08-26 Thread Sam Boyer
Hmm, I hadn't thought about that. But doing that might actually make it worth using as a library. There are definitely a couple things I wouldn't be able to replicate, but I'll think about it. In the meantime...PRs welcome :) On Thursday, August 25, 2016 at 12:41:17 PM UTC-4, Nick Craig-Wood

Re: [go-nuts] Is uppercase relevant at all for labels

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 2:12 PM, Jonathan Frisco wrote: > I'm relatively new to Go, so this may be an obvious question, but I couldn't > find the answer by searching... > > All examples of statement labels I have seen (e.g. > https://golang.org/ref/spec#Break_statements) use

[go-nuts] Is uppercase relevant at all for labels

2016-08-26 Thread Jonathan Frisco
I'm relatively new to Go, so this may be an obvious question, but I couldn't find the answer by searching... All examples of statement labels I have seen (e.g. https://golang.org/ref/spec#Break_statements) use labels where the first character of the label name is capitalized, as if they are

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Volker Dobler
Am Freitag, 26. August 2016 21:13:16 UTC+2 schrieb xiio...@gmail.com: > > *[...] *I haven't checked the compiler code for this but would bet that > currently there is no step disallowing such an assignment. > Well, there is. As you noticed you cannot assign []Age to []int because the compiler

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Volker Dobler
Ahhrg, sorry, sorry, sorry! My reply to this message should have gone to the last one of user T L not yours. I'd like to blame the Web UI, but it was just me being lazy. Sorry. V. Am Freitag, 26. August 2016 21:13:16 UTC+2 schrieb xiio...@gmail.com: > > *"I feel the effort is made to forbid

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
As an aside - there is a complication to this if this (original post) were allowed/added to the language specification var ( a float32 = 1.0 aa []float32 = []float32{1.0, 2.0, 3.0} ) b := float64(a) //is ok bb := ([]float64)(aa) //not ok If the second conversion bb was allowed it

[go-nuts] Re: Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread xiiophen
*"I feel the effort is made to forbid converting []Age into []int instead now."* I don't agree that allowing this conversion would be 'easier' than not allowing. Allowing it requires the additional step of splitting/extracting from the slice the element type and checking that (for

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 1:43:03 AM UTC+8, Axel Wagner wrote: > > The effort is putting a special case into the language for this. > I feel the effort is made to forbid converting []Age into []int instead now. > > On Fri, Aug 26, 2016 at 7:11 PM, T L > wrote: >

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread 'Axel Wagner' via golang-nuts
The effort is putting a special case into the language for this. On Fri, Aug 26, 2016 at 7:11 PM, T L wrote: > > > On Saturday, August 27, 2016 at 12:36:58 AM UTC+8, Axel Wagner wrote: >> >> There is none. It would be perfectly possible and reasonable to make this >>

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread 'Axel Wagner' via golang-nuts
There is none. It would be perfectly possible and reasonable to make this possible, but it probably didn't seem worth the effort to introduce this special case into the language which has such a limited use. If you can't live without, you can always use unsafe to do it yourself (though, of course,

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
On Saturday, August 27, 2016 at 12:05:28 AM UTC+8, Jan Mercl wrote: > > > > On Fri, Aug 26, 2016, 17:59 T L wrote: > >> >> >>> -- >>> >> >> why the underlying types of []Age and []int are not the same. >> > > The underlying type of an anonymous type []T is []T. > > > What

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:59 T L wrote: > > >> -- >> > > why the underlying types of []Age and []int are not the same. > The underlying type of an anonymous type []T is []T. -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:45 T L wrote: > > > package main > > type Age int > > func main() { > var ages = []Age{17, 18, 19} > var ints = ([]int)(ages) // error: cannot convert ages (type []Age) to > type []int > _ = ints > } > Because Go is a type safe language.

[go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread T L
package main type Age int func main() { var ages = []Age{17, 18, 19} var ints = ([]int)(ages) // error: cannot convert ages (type []Age) to type []int _ = ints } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread Aliaksandr Valialkin
It looks like there is a timeout (aka deadline) set on the connection, so small responses are sent without problems, while large responses are interrupted by the timeout. See https://blog.cloudflare.com/the-curious-case-of-slow-downloads/ for details. On Thursday, January 28, 2016 at 7:06:38

[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-26 Thread T L
On Thursday, August 25, 2016 at 9:30:01 PM UTC+8, xiio...@gmail.com wrote: > > 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

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

2016-08-26 Thread Asit Dhal
Hi, If you really need to calculate total, you should leave that completely to the view layer(client side java script). On Fri, Aug 26, 2016 at 8:55 AM, Simon Ritchie wrote: > If you follow the Model View Controller (MVC) model, you should do all of > the clever

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

2016-08-26 Thread Aliaksandr Valialkin
Hi Carl, try quicktemplate instead of html/template. It supports arbitrary data transformations inside the template code, so the 'totals' row may be easily implemented without external code: Suppose you have the following row struct: type Row struct

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 7:36 AM, wrote: >> Interesting. Maybe we need to change this line in setsig in >> runtime/os_darwin.go >> *(*uintptr)(unsafe.Pointer(__sigaction_u)) = fn >> to be >> *(*uintptr)(unsafe.Pointer(__sigaction_u)) = >>

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread martin . strenge
> > Interesting. Maybe we need to change this line in setsig in > runtime/os_darwin.go > *(*uintptr)(unsafe.Pointer(__sigaction_u)) = fn > to be > *(*uintptr)(unsafe.Pointer(__sigaction_u)) = > unsafe.Pointer(funcPC(sigtramp)) > That's not possible, the signatures of sa_tramp and

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

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 2:56 AM, Cholerae Hu wrote: > I'm curious that how does compiler recognize runtime.KeepAlive specially? The compiler already recognizes some functions specially, most notably math.Sqrt. Search for "Sqrt" in cmd/compile/internal/gc/walk.go. Ian >

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread Ian Lance Taylor
On Fri, Aug 26, 2016 at 6:35 AM, wrote: > > The reason for the morestack call is, that sigtramp is not called in my code > example. The sa_tramp seems to be overwritten in my call to > sigaction(int,struct sigaction*,struct sigaction*) and I cannot retrieve the >

Re: [go-nuts] runtime: split stack overflow

2016-08-26 Thread martin . strenge
Hi, It took a while to understand what's going on. > I'm not sure which part of the os/signal docs you are thinking of. I'm referring to "Go programs that use cgo or SWIG", last paragraph ("If the Go signal handler is invoked on a non-Go thread not running Go code [...]"). I couldn't get

Re: [go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread James Bardin
On Fri, Aug 26, 2016 at 5:46 AM, wrote: > I found it's hard to match *this particular error (*"broken pipe"*)*, and > handle it accordingly, is there a solution? > What do you want to do with this particular error? How would you handle it differently than any other

[go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread siliang . cao
I found it's hard to match *this particular error (*"broken pipe"*)*, and handle it accordingly, is there a solution? On Friday, January 29, 2016 at 1:06:38 AM UTC+8, vijayan jay wrote: > > We are using net.Conn.Write(response) in our program were response is a > json data of length 84317829

[go-nuts] Continous Inspection of Go Code Quality

2016-08-26 Thread DM
Is there any tool available in GoLang for the Continuous Inspection of code quality something similar to SonarQube ? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

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

2016-08-26 Thread Dave Cheney
runtime/mfinal.go:464 On Friday, 26 August 2016 19:56:49 UTC+10, Cholerae Hu wrote: > > I'm curious that how does compiler recognize runtime.KeepAlive specially? > > 在 2016年8月26日星期五 UTC+8上午12:04:57,Ian Lance Taylor写道: >> >> On Thu, Aug 25, 2016 at 12:15 AM, Cholerae Hu >>

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

2016-08-26 Thread Carl Ranson
Ok, Thanks for the answers. I've gone down the route of adding totals to my data structure. cheers, CR. -- 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

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

2016-08-26 Thread Cholerae Hu
I'm curious that how does compiler recognize runtime.KeepAlive specially? 在 2016年8月26日星期五 UTC+8上午12:04:57,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

[go-nuts] Call COM object method from Go without CGo

2016-08-26 Thread lars.scheme via golang-nuts
I have created a Direct3D9 wrapper in Go which uses CGo to interface with the COM objects in C. (https://github.com/gonutz/d3d9) I would like to get rid of the dependency on a C-compiler under Windows so the user would not have to install MinGW or Cygwin to use DirectX from Go. The problem is

Re: [go-nuts] Re: Confused about defer

2016-08-26 Thread dc0d
Yes; it seemed to me that the return statement would get evaluated even after a panic. I thought of it as a special case of a deferred context - confused. Thank you very much; On Friday, August 26, 2016 at 12:11:03 PM UTC+4:30, Axel Wagner wrote: > > I'd think, the spec is reasonably

[go-nuts] Re: Confused about defer

2016-08-26 Thread pierre . curto
To me this works as expected. In both your versions, the return statement in Recover() is not even reached since the call to f panics. You recover from the panic in your defer statement and assign the err variable your error value. Since in your first version, that variable is not returned,

Re: [go-nuts] Re: Confused about defer

2016-08-26 Thread 'Axel Wagner' via golang-nuts
I'd think, the spec is reasonably unambiguous, if not very explicit. The second version works, because of For instance, if the deferred function is a function literal and the > surrounding function has named result parameters that are in scope within > the literal, the deferred function may

[go-nuts] Re: Confused about defer

2016-08-26 Thread dc0d
There deferred function here has not any return value - to get discarded. It rather assigns a value to the *closure* *err* variable. Since a defer statement "*invokes a function whose execution is deferred to the moment the surrounding function returns*", so I expected the *err* variable

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

2016-08-26 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