Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Kurtis Rader
Your example is a C program. I'm guessing you're using gccgo to link with equivalent C code. In which case your question has almost nothing to do with Go. You need to ask the Linux community why your example results in a defunct process that appears to have a live thread. I do not believe you

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Uday Kiran Jonnala
Thanks Kurtis for the reply. I understand defunct process mechanism. As I mentioned in the initial mail, [Correct me if I am wrong here], In a process if there is main thread and a detached thread created by main thread, when the main thread exits the process is kept in defunct state, since

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Kurtis Rader
On Thu, Sep 10, 2020 at 9:25 PM Uday Kiran Jonnala wrote: > Thanks for the reply. We are fixing the issue. But the point I wanted to > bring it up here is the issue of a thread causing the go process to be in > defunct state. > Any thread can cause the go process to enter the "defunct" state.

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Uday Kiran Jonnala
Hi Ian, Kurtis, Thanks for the reply. We are fixing the issue. But the point I wanted to bring it up here is the issue of a thread causing the go process to be in defunct state. My kernel version is Linux version 4.14.175-1.nutanix.20200709.el7.x86_64 (dev@ca4b0551898c) (gcc version 7.3.1

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Ian Lance Taylor
On Thu, Sep 10, 2020 at 5:09 PM Kurtis Rader wrote: > > A defunct process is a process that has terminated but whose parent process > has not called wait() or one of its variants. I don't know why lsof still > reports open files. It shouldn't since a dead process should have its > resources,

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Ian Lance Taylor
On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills wrote: > > I have this helper func to print memory usage (detect a memory leak?) > > > func PrintMemUsage() { > var m runtime.MemStats > runtime.ReadMemStats() > // For info on each, see: https://golang.org/pkg/runtime/#MemStats > fmt.Printf("Alloc

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Kurtis Rader
A defunct process is a process that has terminated but whose parent process has not called wait() or one of its variants. I don't know why lsof still reports open files. It shouldn't since a dead process should have its resources, such as its file descriptor table, freed by the kernel even if the

Re: [go-nuts] Running goanalyzer on golang process running inside kubernetes pod

2020-09-10 Thread robert engels
goanalyzer = go tool trace The options to goanalyzer are the same as ‘go tool trace’ - the usage message is misleading in this way. By ‘map’ I mean expose the pprof port as you would any other port, and yes you use the net/http/pprof to start the internal webserver - you don’t need to create

Re: [go-nuts] zombie parent scenario with golang

2020-09-10 Thread Uday Kiran Jonnala
Hi Ian, Again. Thanks for the reply. Problem here is we see go process is in defunt process and sure parent process did not get SIGCHILD and looking deeper, I see a thread in futex_wait_queue_me. If we think we are just getting the stack trace and the go process actually got killed, why would

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Alexander Mills
I stole the memory code from here: https://golangcode.com/print-the-current-memory-usage/ On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills wrote: > > I have this helper func to print memory usage (detect a memory leak?) > > > func PrintMemUsage() { > var m runtime.MemStats >

[go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Alexander Mills
I have this helper func to print memory usage (detect a memory leak?) func PrintMemUsage() { var m runtime.MemStats runtime.ReadMemStats() // For info on each, see: https://golang.org/pkg/runtime/#MemStats fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc)) fmt.Printf("\tTotalAlloc = %v MiB",

Re: [go-nuts] Running goanalyzer on golang process running inside kubernetes pod

2020-09-10 Thread Siddhesh Divekar
Hi Robert, Laying down the steps to make sure I understood it correctly. You can map the port > What did you mean by above ? but might be easier to capture to a file via code and use goanalyzer on the > file > In this case I will do the following. a) Set up a webserver in my program for getting

Re: [go-nuts] godoc-static - Generate static documentation for your packages

2020-09-10 Thread Trevor Slocum
godoc-static v0.1.8 is now available featuring improved support for Go modules. On Wednesday, February 26, 2020 at 3:45:49 PM UTC-8 Trevor Slocum wrote: > I've had some time to polish this project somewhat. It should be fairly > usable. > > I've added ZIP archive generation to allow browsing

Re: [go-nuts] why is wait group necessary here?

2020-09-10 Thread burak serdar
On Thu, Sep 10, 2020 at 4:43 PM Alexander Mills wrote: > > It was behaving strangely before adding the waitgroup, my script was > getting stuck Waitgroup is unnecessary. There's a few problems: when you detect an error you should stop writing, but the program "continue"s. You set the

Re: [go-nuts] add method to interface via reflect

2020-09-10 Thread Kurtis Rader
On Thu, Sep 10, 2020 at 3:44 PM Vasiliy Tolstov wrote: > Hi! Does go support adding method to exiting interface via reflect? > Mostly I need to add method to struct pointer. > No, and this sounds like an XY problem . It would help if you described the problem rather than

[go-nuts] add method to interface via reflect

2020-09-10 Thread Vasiliy Tolstov
Hi! Does go support adding method to exiting interface via reflect? Mostly I need to add method to struct pointer. -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] why is wait group necessary here?

2020-09-10 Thread Alexander Mills
It was behaving strangely before adding the waitgroup, my script was getting stuck On Thu, Sep 10, 2020 at 11:14 AM burak serdar wrote: > > On Thu, Sep 10, 2020 at 11:46 AM Alexander Mills > wrote: > > > > I tried writing this http post request which streams the request body > > line-by-line

Re: [go-nuts] Running goanalyzer on golang process running inside kubernetes pod

2020-09-10 Thread Robert Engels
You can map the port but might be easier to capture to a file via code and use goanalyzer on the file. > On Sep 10, 2020, at 4:53 PM, Siddhesh Divekar > wrote: > >  > Hi, > > Has anyone tried running goanalyzer on golang process running inside k8s pod. > > If so can you point me to the

[go-nuts] Running goanalyzer on golang process running inside kubernetes pod

2020-09-10 Thread Siddhesh Divekar
Hi, Has anyone tried running goanalyzer on golang process running inside k8s pod. If so can you point me to the steps. -- -Siddhesh. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 11:58 PM Yonatan Gizachew wrote: > > Also, is there a way to print the values of runtime.g? In what sense? Code running the runtime package can just print it. Or if you run the program under gdb, you should be able to "print 'runtime.g'" (you need the quotes because

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Ian Lance Taylor
On Wed, Sep 9, 2020 at 11:55 PM Yonatan Gizachew wrote: > > Thank you for the explanation. For example, please have a look at the this bt. > __tls_get_addr is called after runtime.getg. So, what does __tls_get_addr > return at this time, a pointer to runtime.g or runtime.g itself? If I recall

Re: [go-nuts] why is wait group necessary here?

2020-09-10 Thread burak serdar
On Thu, Sep 10, 2020 at 11:46 AM Alexander Mills wrote: > > I tried writing this http post request which streams the request body > line-by-line as JSON. > (This is for an ElasticSearch bulk api request, newline separate JSON in the > request body). I didn't think the waitgroup was necessary,

[go-nuts] why is wait group necessary in streaming post request to elasticsearch

2020-09-10 Thread Alexander Mills
I am trying to figure out why the wg is seemingly necessary as part of this code to stream JSON to a post request to ElasticSearch: https://gist.github.com/ORESoftware/06341057ca39e1b2a47dc8a8e4e4b55f Any tips appreciated. If the waitgroup is not used, it doesn't appear to wait until the full

[go-nuts] why is wait group necessary here?

2020-09-10 Thread Alexander Mills
I tried writing this http post request which streams the request body line-by-line as JSON. (This is for an ElasticSearch bulk api request, newline separate JSON in the request body). I didn't think the waitgroup was necessary, but apparently the waitgroup is necessary. Does anyone know why? I

Re: [go-nuts] [generics] Allowing interfaces with type constraints

2020-09-10 Thread Viktor Kojouharov
I see, I guess the compiler error message needs improvement here. It could mention that interfaces with type lists cannot be used. On Thursday, September 10, 2020 at 5:17:57 PM UTC+2 rog wrote: > You can definitely use parametric interfaces in type assertion > expressions, but you can't use

Re: [go-nuts] [generics] Allowing interfaces with type constraints

2020-09-10 Thread roger peppe
You can definitely use parametric interfaces in type assertion expressions, but you can't use interfaces with type lists. I'm not sure exactly what you're trying to do in your example, but ISTM that it could be somewhat simpler. You only need one type parameter:

Re: [go-nuts] Is there any lib like CMSSignedData in GOLANG?

2020-09-10 Thread liuhanlin
https://github.com/jack0liu/pbkdf2 发自我的iPhone > 在 2020年9月10日,上午2:00,Somporn pongpan 写道: > > Can you share the code or any info for decryption with pkcs7? > >> On Wednesday, June 8, 2016 at 7:51:40 AM UTC+7 18126...@163.com wrote: >> It's great. >> >> In fact , I have found some code using

[go-nuts] [generics] Allowing interfaces with type constraints

2020-09-10 Thread Viktor Kojouharov
Would using parametric interfaces be allowed in type assertion expressions / type switches? The current behavior in the go2go playground is for the compiler to return the error: "interface contains type constraints (T)" (https://go2goplay.golang.org/p/O1Un2Vm9Dh0) I was under the impression

Re: [go-nuts] Is there any lib like CMSSignedData in GOLANG?

2020-09-10 Thread liuhanlin
https://github.com/jack0liu/pbkdf2 if it works,thanks for giving a star 发自我的iPhone > 在 2020年9月10日,上午2:00,Somporn pongpan 写道: > > Can you share the code or any info for decryption with pkcs7? > >> On Wednesday, June 8, 2016 at 7:51:40 AM UTC+7 18126...@163.com wrote: >> It's great. >> >>

Re: [go-nuts] Workflow and tools for JSON Schema generation

2020-09-10 Thread Paul Jolly
CUE (https://cuelang.org/) will (in the near future) be able to help with the Go -> JSON Schema part (or indeed JSON Schema -> Go). Please feel free to ask any questions of the community via https://cuelang.org/community/ On Thu, 3 Sep 2020 at 08:05, Johann Höchtl wrote: > > > Hi, > I would

Re: [go-nuts] unit test for function which has goroutine

2020-09-10 Thread Gregor Best
Right, I wanted to write something about the goroutine and forgot about it. Sorry about that. The problem here could be that in the code you posted there's nothing waiting on any result from the goroutine, and if the test exits quickly enough, it might not get scheduled. In general,

Re: [go-nuts] unit test for function which has goroutine

2020-09-10 Thread Yvonne Zhang
Thank you Gregor for your quick reply! Anything special I need to think about this go routine logic in my unit test. It might be still running after test returns..? On Thursday, September 10, 2020 at 5:26:13 PM UTC+10 be...@pferdewetten.de wrote: > If I were you, I'd pass in an interface

Re: [go-nuts] unit test for function which has goroutine

2020-09-10 Thread Gregor Best
If I were you, I'd pass in an interface value to functionA with the signature type Ber interface{ functionB(io.Reader, io.Writer) } (assuming that zipReader is an io.Reader, zipWriter is an io.Writer, you may have to adjust this a bit). Then make your mock

[go-nuts] unit test for function which has goroutine

2020-09-10 Thread Yvonne Zhang
Hi, I have a function streaming a zipreader to browser. It is like this. func functionA()(body io.ReadCloser, err error){ // some logic to get a zipreader body, pipeWriter := io.Pipe() zipWriter := zip.NewWriter(pipeWriter) go func(){ // err := functionB(zipReader,

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Yonatan Gizachew
Also, is there a way to print the values of runtime.g? On Thursday, September 10, 2020 at 12:15:04 PM UTC+9 Ian Lance Taylor wrote: > On Wed, Sep 9, 2020 at 7:39 PM Yonatan Gizachew wrote: > > > > This might be trivial, but could you explain me the relationship between > the following? > > 1.

Re: [go-nuts] Running golang C-shared library in an OS that uses cooperative scheduling.

2020-09-10 Thread Yonatan Gizachew
Thank you for the explanation. For example, please have a look at the this bt. __tls_get_addr is called after runtime.getg. So, what does __tls_get_addr return at this time, a pointer to runtime.g or runtime.g itself? On