Re: [go-nuts] How can i create a counter decorator in go?

2019-11-01 Thread burak serdar
On Sat, Nov 2, 2019 at 12:20 AM 林风 wrote: > > let's say i have a function or method to get fib > > func fib(n int){ > ... > return fib(n-1) + fib(n-2) > } > > > now i want to add a counter to track how many times i have called to fib. > > in python or jave i can easy use `decorator patten` to

[go-nuts] How can i create a counter decorator in go?

2019-11-01 Thread 林风
let's say i have a function or method to get fib func fib(n int){ ... return fib(n-1) + fib(n-2) } now i want to add a counter to track how many times i have called to fib. in python or jave i can easy use `decorator patten` to do it. but in go, you can not change fib since it is a functi

Re: [go-nuts] Any non-split 'print' functions available?

2019-11-01 Thread Aram Hăvărneanu
For this type of thing I'd recommend a debugger. -- Aram Hăvărneanu -- 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. To

Re: [go-nuts] Automatically releasing memory resources allocated in cgo?

2019-11-01 Thread Tom Payne
Thank you very much for the fast, clear, and detailed answer :) On Fri, 1 Nov 2019 at 15:08, Ian Lance Taylor wrote: > On Fri, Nov 1, 2019 at 6:31 AM Tom Payne wrote: > > > > cgo is often used to provide bindings to C libraries. Any memory > allocated in the C library is not visible to Go, so G

[go-nuts] Go servers should return 308 for non-GET methods

2019-11-01 Thread rfgrimm
Hi all, Apologies if this has been discussed before. I searched and didn't find anything. There are a few places in http/server.go that will redirect with 301s and that could cause clients, including Go's client, to change the method to a GET. One place/condition when it does this kind of re

Re: [go-nuts] How to kill running function from core golang libraries

2019-11-01 Thread burak sarac
Thank you all for your response Jake - thank you for clarification and yes you are correct. Application works like checksum validation server,client. Terminate is only useful if user triggered server to download a very large file but figured wrong setting present and i.e. does ctrl+c on client y

Re: [go-nuts] How to kill running function from core golang libraries

2019-11-01 Thread burak serdar
On Fri, Nov 1, 2019 at 8:07 AM burak sarac wrote: > > I have a go routine running something like 'hash.sum(data)' using import > "hash" that I want to terminate immediately in case of user wants to kill, I > can not send channel to notify. I only can think of copying implementation > but then

Re: [go-nuts] How to kill running function from core golang libraries

2019-11-01 Thread Jake Montgomery
On Friday, November 1, 2019 at 10:30:50 AM UTC-4, Shulhan wrote: > > > On Fri, 1 Nov 2019, 21:07 burak sarac, > > wrote: > >> I have a go routine running something like 'hash.sum(data)' using import >> "hash" that I want to terminate immediately in case of user wants to >> kill, I can not send

[go-nuts] Re: Automatically releasing memory resources allocated in cgo?

2019-11-01 Thread Jake Montgomery
Ian's advice seems sound. But there is one other option to consider. When practical, I like to simply copy C allocated memory to Go allocated memory in the wrapper for the cgo call, and free the C memory immediately. This removes the insanity of keeping track of C memory in Go. Obviously there

Re: [go-nuts] http: superfluous response.WriteHeader call

2019-11-01 Thread Mhd Shulhan
On Fri, 1 Nov 2019, 00:13 , wrote: > help me! > > web connect database and show view. when press f5 repeatedly > command line show http: superfluous response.WriteHeader > call... > My guess is that you call response.WriteHeader in your code. Check again, and make sure its only call

Re: [go-nuts] How to kill running function from core golang libraries

2019-11-01 Thread Mhd Shulhan
On Fri, 1 Nov 2019, 21:07 burak sarac, wrote: > I have a go routine running something like 'hash.sum(data)' using import > "hash" that I want to terminate immediately in case of user wants to > kill, I can not send channel to notify. > I have not tried this, but you can use a combination of de

Re: [go-nuts] Automatically releasing memory resources allocated in cgo?

2019-11-01 Thread Ian Lance Taylor
On Fri, Nov 1, 2019 at 6:31 AM Tom Payne wrote: > > cgo is often used to provide bindings to C libraries. Any memory allocated in > the C library is not visible to Go, so Go does not have an accurate view of > the program's memory usage and does not run the garbage collector or any > finalizers

[go-nuts] How to kill running function from core golang libraries

2019-11-01 Thread burak sarac
I have a go routine running something like 'hash.sum(data)' using import " hash" that I want to terminate immediately in case of user wants to kill, I can not send channel to notify. I only can think of copying implementation but then I have to watch each update on library which I really dont wa

Re: [go-nuts] Any non-split 'print' functions available?

2019-11-01 Thread Ian Lance Taylor
On Thu, Oct 31, 2019 at 11:44 PM Xiangdong JI wrote: > > Thanks Ian, having difficulty figuring out how to print a pointer using > write1, could you please shed a light? Thanks. You have to do something like (untested) var buf [20]byte b := itoa(buf[:], uint64(uintptr(ptrToPrint)))

[go-nuts] Automatically releasing memory resources allocated in cgo?

2019-11-01 Thread Tom Payne
cgo is often used to provide bindings to C libraries. Any memory allocated in the C library is not visible to Go, so Go does not have an accurate view of the program's memory usage and does not run the garbage collector or any finalizers often enough. Consequently, memory usage for a Go server t

[go-nuts] Re: Go 1.13.4 and Go 1.12.13 are released

2019-11-01 Thread Stephen Illingworth
Build fails here. Using v1.13 to build: go test proxy running at GOPROXY=http://127.0.0.1:41805/mod go proxy: no archive rsc.io v1.5.2: file does not exist go proxy: no archive rsc.io v1.0.0: file does not exist go proxy: no archive rsc.io v1.0.0: file does not exist go proxy: no archive rsc.io v1

[go-nuts] Re: Roadblock for user-implemented JIT compiler

2019-11-01 Thread Sokolov Yura
Don't forget about calling to write barriers. -- 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. To view this discussion o