Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Jan Mercl
On Sat, Aug 24, 2019 at 5:25 AM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Kurtis Rader
On Fri, Aug 23, 2019 at 10:11 PM Lee Rick wrote: > it's not my need, hope other methods > Then you need to explain why that answer is not satisfactory and otherwise better explain your requirements. In your hypothetical example the objects such as `d1` would not be usable except via reflection

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread burak serdar
On Fri, Aug 23, 2019 at 11:11 PM Lee Rick wrote: > > it's not my need, hope other methods What is your need? What are the types of the variables d1, d2, d3 in your example? > > 在 2019年8月24日星期六 UTC+8上午11:43:32,burak serdar写道: >> >> On Fri, Aug 23, 2019 at 9:25 PM Lee Rick wrote: >> > >> > i

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Lee Rick
it's not my need, hope other methods 在 2019年8月24日星期六 UTC+8上午11:43:32,burak serdar写道: > > On Fri, Aug 23, 2019 at 9:25 PM Lee Rick > > wrote: > > > > i want to do > > type A struct{ Name string} > > type B struct{Age int} > > type C struct{Address string} > > > > a, b, c := A{}, B{},C{} >

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread burak serdar
On Fri, Aug 23, 2019 at 9:25 PM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

[go-nuts] how to merge different struct to one struct

2019-08-23 Thread Lee Rick
i want to do type A struct{ Name string} type B struct{Age int} type C struct{Address string} a, b, c := A{}, B{},C{} have a function d1 := merge(a,b) //d1 like struct{Name string, Age int} d2 := merge(a,c) //d2 like struct{Name string, Address string} d3 := merge(b,c) //d3 like struct{Age

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Michael Andersen
This is built with go 1.12.5, incidentally, but I have seen this on several go versions spanning several months. On Fri, Aug 23, 2019 at 7:36 PM Michael Andersen wrote: > Ok, so I have more information, and it's not what I would expect. > > I added scheddetail=1,schedtrace=2000 so that I had a

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Michael Andersen
Ok, so I have more information, and it's not what I would expect. I added scheddetail=1,schedtrace=2000 so that I had a list of which M's and G's were on the P's during the 5 seconds that scheduling stalled. I added a sentinel goroutine that sleeps 1 second in a loop and panics if the sleep takes

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Ian Lance Taylor
On Fri, Aug 23, 2019 at 2:30 PM Michael Andersen wrote: > > Are you suggesting that there might be enough unpreemtable goroutines to fill > all the P's? I do have several cgo goroutines sitting in syscalls, but my > understanding was that the scheduler would "preempt" that by moving the M off

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Michael Andersen
On Fri, Aug 23, 2019 at 2:12 PM Robert Engels wrote: > If you write an long running non pre-emptable all go routines are > effected. > > Yeah, I've come across the case before where GC would begin a stop the world but get stuck waiting for a non-preemtable goroutine. I don't think that's

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Robert Engels
If you write an long running non pre-emptable all go routines are effected. > On Aug 23, 2019, at 4:03 PM, Michael Andersen wrote: > > > >> On Fri, Aug 23, 2019 at 1:23 PM Ronny Bangsund >> wrote: >>> On Friday, August 23, 2019 at 5:58:44 PM UTC+2, Michael Andersen wrote: >>> It can take a

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Michael Andersen
On Fri, Aug 23, 2019 at 1:23 PM Ronny Bangsund wrote: > On Friday, August 23, 2019 at 5:58:44 PM UTC+2, Michael Andersen wrote: >> >> It can take a while to reproduce, so it might be a week or so before I >> have the results. >> > Can you think of ways to cause the same memory pressure quicker?

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Ronny Bangsund
On Friday, August 23, 2019 at 5:58:44 PM UTC+2, Michael Andersen wrote: > > It can take a while to reproduce, so it might be a week or so before I > have the results. > Can you think of ways to cause the same memory pressure quicker? Mocking data, running the functions the number of times they

Re: [go-nuts] Goroutine scheduled 10 seconds too late

2019-08-23 Thread Michael Andersen
Thanks, that's a good idea. I'll add that in. It can take a while to reproduce, so it might be a week or so before I have the results. On Thu, Aug 22, 2019 at 10:23 PM Ian Lance Taylor wrote: > On Thu, Aug 22, 2019 at 5:09 PM wrote: > > > > I have a fairly complex program that has about 150

Re: [go-nuts] Get tmp stuff in $GOTMPDIR instead of /tmp?

2019-08-23 Thread Ian Lance Taylor
On Fri, Aug 23, 2019 at 7:34 AM Peter Weinberger (温博格) wrote: > > This is routinely happening to me too, on linux. My go commands are go build > *.go > The left-over directories are empty > I'm on go1.12.5 linux/amd64 Well, that is ungood. And I don't see it myself. Can you figure out a way

Re: [go-nuts] Get tmp stuff in $GOTMPDIR instead of /tmp?

2019-08-23 Thread 温博格
This is routinely happening to me too, on linux. My go commands are go build *.go The left-over directories are empty I'm on go1.12.5 linux/amd64 On Fri, Aug 23, 2019 at 10:04 AM Ian Lance Taylor wrote: > On Thu, Aug 22, 2019 at 7:55 AM wrote: > > > > I get a bloated /tmp-dir (in just a few

Re: [go-nuts] Get tmp stuff in $GOTMPDIR instead of /tmp?

2019-08-23 Thread Ian Lance Taylor
On Thu, Aug 22, 2019 at 7:55 AM wrote: > > I get a bloated /tmp-dir (in just a few days I get tens of thousands of > folders named /tmp/go-build828718408 etc.) That is odd in itself. The go-buildN directories should normally be deleted when the go command completes. Are you routinely