[go-nuts] Re: Strange redirect behavior with http.StripPrefix

2023-12-19 Thread j2gg0s
Why this happens: 1. http.StripPrefix chang reuqest's path from /some/other/path to other/path 2. ServerMux.Handler will return 301 when cleanPath(r.URL.Path) != r.URL.Path Link: https://github.com/golang/go/blob/go1.21.5/src/net/http/server.go#L2467 This seems to be a issue with ServerMux, Our

[go-nuts] Re: Why golang's garbage collector didn't free obj when an finalizer is associate with it?

2023-11-06 Thread j2gg0s
Just my(newbie of GC) guess: In the mark stage, - GC find s1's finalizer and invoke scanobject to scan s1 https://github.com/golang/go/blob/go1.21.1/src/runtime/mgcmark.go#L391 https://github.com/golang/go/blob/go1.21.1/src/runtime/mfinal.go#L484 - then find s2 and queue it to be scanned -

[go-nuts] Re: Question in Converting float64 to uint64

2023-10-25 Thread j2gg0s
Just my guess: - when use IEE754, 18446744073709551615 will be actual stored as 18446744073709551616 (> 2<<64) - so uint64(float64(18446744073709551615)) is overflow and undefined Code: // true fmt.Println(uint64(float64(18446742974197923840)) == uint64(18446742974197923840)) // cannot convert

[go-nuts] Re: URL variables with net/http

2023-10-19 Thread j2gg0s
I'm not sure what the best way is. But I think you can refer to the existing solutions. For example gin, mux. Link: https://github.com/gin-gonic/gin/blob/master/tree.go#L116 在2023年10月19日星期四 UTC+8 19:27:59 写道: > Hi everyone. I'm building an api with net/http and I'm having trouble > with url

Re: [go-nuts] How to understand assembly code related to defer

2023-10-07 Thread j2gg0s
Thanks for the guidance, the corresponding documentation helped me a lot 在2023年9月28日星期四 UTC+8 11:34:21 写道: > On Tue, Sep 26, 2023 at 11:06 PM j2gg0s wrote: > > > > Related go code: > > 22 //go:noinline > > 23 func add(a, b int) int { > > 24 defer func

Re: [go-nuts] How to understand assembly code related to defer

2023-09-27 Thread j2gg0s
enhancement > proposal, that answers your question at the level of detail of > specific instruction sequences. > > On Tue, Sep 26, 2023 at 9:10 PM j2gg0s wrote: > >> Thanks @lan >> >> Already read it, I actually started here. >> >> What I can't und

Re: [go-nuts] How to understand assembly code related to defer

2023-09-27 Thread j2gg0s
"main.add.func1>:" -A 31 0047aee0 : 2.3 i just found 0x49b4e8 in rodata 2.4 So, What is stored at 0x49b4e8? 在2023年9月27日星期三 UTC+8 12:44:10 写道: > On Tue, Sep 26, 2023 at 9:10 PM j2gg0s wrote: > > > > Already read it, I actually started here. > > > > What I can'

Re: [go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
Thanks @lan Already read it, I actually started here. What I can't understand is x64 rip-relative address. leaq132795(%rip), %rcx # 0x49b4e8 why 132795, and what is loaded into rcx 在2023年9月27日星期三 UTC+8 09:38:17 写道: > On Tue, Sep 26, 2023 at 7:43 AM j2gg0s wrote: > >

[go-nuts] Re: How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
Append: 49b4e8: c0 ae 47 00 00 00 00 shrb $0, 71(%rsi) 在2023年9月26日星期二 UTC+8 22:43:27 写道: > How to understand assmbly code ` 47ae26: 48 8d 0d bb 06 02 00 > leaq132795(%rip), %rcx # 0x49b4e8 ` > > Go code: > ``` > //go:noinline > func add(a, b int) int { >

[go-nuts] How to understand assembly code related to defer

2023-09-26 Thread j2gg0s
How to understand assmbly code ` 47ae26: 48 8d 0d bb 06 02 00 leaq132795(%rip), %rcx # 0x49b4e8 ` Go code: ``` //go:noinline func add(a, b int) int { defer func() { fmt.Println(3) }() return a + b } func main() { add(10, 20) }

Re: [go-nuts] How to understand runtime.gogo?

2023-01-18 Thread j2gg0s
Thanks, solved my problem 在2023年1月17日星期二 UTC+8 00:49:03 写道: > On Mon, Jan 16, 2023 at 8:43 AM j2gg0s wrote: > > > > As a newbie of golang's assembly, i cant understand why we MOVQ DX CX > twice in runtime.gogo. WHY? > > I don't see any MOVQ DX, CX instructions here. Can

[go-nuts] How to understand runtime.gogo?

2023-01-16 Thread j2gg0s
As a newbie of golang's assembly, i cant understand why we MOVQ DX CX twice in runtime.gogo. WHY? Source code: ``` 255 // func gogo(buf *gobuf) 256 // restore state from Gobuf; longjmp 257 TEXT runtime·gogo(SB), NOSPLIT, $0-8 258 MOVQbuf+0(FP), BX // gobuf