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
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
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
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
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
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
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
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
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
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
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
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
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
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)))
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
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
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
17 matches
Mail list logo