Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Ian Lance Taylor
On Wed, Jan 18, 2023 at 8:08 PM Andrew Athan wrote: > > The remaining issue is that, irrespective of the "wideness" of the "any" type > constraint, which apparently includes non-comparable types, the resolution of > v's type is to a comparable type, yet the error is still emitted. The body of t

Re: [go-nuts] Endlessly increasing CPU usage problem

2023-01-18 Thread Danny Carr
@Rustam Abdullaev you're a lifesaver!! I was having this same issue with rising CPU and was going crazy trying to find the resource leak until I saw your comment - pulled up a heap dump and saw 75% time.NewTicker, found a dangling ticker I was instantiating in a goroutine, added a defer ticker.

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Andrew Athan
Ian: Thanks. The example I posted is a silly uber short simplification of my usecase. In fact, have a complex struct with a large set of methods and only one of the methods requires comparable types; it'd be nice to not have to constrain to comparable at the struct level, and only have actual

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Andrew Athan
By the way, what is the idiomatic way to assert that a variable that is type constrained as "any" in the generic declaration, is in fact comparable (if there is a way)? I.e., in my example "Foo" function, is there a way for me to further constrain (or rather, assert that) v's type is comparable

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Andrew Athan
Thank you for the practical tip on how to avoid the error. The wording of the error could be improved, IMHO, and there is a remaining issue I raised which is not addressed by the suggestion to use the "comparable" constraint (btw, the documentation I've so far been served up by duckduckgo when

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Ian Lance Taylor
On Wed, Jan 18, 2023 at 6:58 PM Christian Stewart wrote: > > On Wed, Jan 18, 2023 at 6:56 PM Ian Lance Taylor wrote: > > > // IsEmpty checks if the interface is equal to nil. > > > func IsEmpty[T Block](blk T) bool { > > > var empty T > > > return empty == blk > > > } > > > > > > (I had b

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Ian Lance Taylor
On Wed, Jan 18, 2023 at 4:52 PM Andrew Athan wrote: > > (Possibly related to issues such as those discussed in > https://groups.google.com/g/golang-nuts/c/pO2sclKEoQs/m/5JYjveKgCQAJ ?) > > If I do: > > ``` > func Foo[V any](v V)bool { > return v==v > } > ``` > > golang 1.19 reports: > > ``` > i

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
Hi Ian, all, On Wed, Jan 18, 2023 at 6:56 PM Ian Lance Taylor wrote: > > // IsEmpty checks if the interface is equal to nil. > > func IsEmpty[T Block](blk T) bool { > > var empty T > > return empty == blk > > } > > > > (I had blk Block before, instead of blk T). > > > > Comparing with emp

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Ian Lance Taylor
On Wed, Jan 18, 2023 at 6:28 PM 'Christian Stewart' via golang-nuts wrote: > > Thing is an interface in the first example I gave: > > If you want to compare two interfaces: > > var foo1 Thing > var foo2 Thing > > Ordinarily you can do foo1 == foo2 and it does pointer-wise comparison. It's true th

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
Kurtis, Thing is an interface in the first example I gave: If you want to compare two interfaces: var foo1 Thing var foo2 Thing Ordinarily you can do foo1 == foo2 and it does pointer-wise comparison. This absolutely is the case: https://gotipplay.golang.org/p/ODG9xvyVEqs Now, I understand the

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Kurtis Rader
On Wed, Jan 18, 2023 at 5:14 PM 'Christian Stewart' via golang-nuts < golang-nuts@googlegroups.com> wrote: > The thing I ran into with this today was, if you want to compare two > interfaces: > > var foo1 Thing > var foo2 Thing > > Ordinarily you can do foo1 == foo2 and it does pointer-wise compar

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread 'Christian Stewart' via golang-nuts
The thing I ran into with this today was, if you want to compare two interfaces: var foo1 Thing var foo2 Thing Ordinarily you can do foo1 == foo2 and it does pointer-wise comparison. But in a generic function, as an example: // IsEmpty checks if the interface is equal to nil. func IsEmpty[T Blo

Re: [go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread burak serdar
On Wed, Jan 18, 2023 at 5:52 PM Andrew Athan wrote: > (Possibly related to issues such as those discussed in > https://groups.google.com/g/golang-nuts/c/pO2sclKEoQs/m/5JYjveKgCQAJ ?) > > If I do: > > ``` > func Foo[V any](v V)bool { > return v==v > } > ``` > > golang 1.19 reports: > > ``` > inv

[go-nuts] Go 1.19 comparison of variables of generic type

2023-01-18 Thread Andrew Athan
(Possibly related to issues such as those discussed in https://groups.google.com/g/golang-nuts/c/pO2sclKEoQs/m/5JYjveKgCQAJ ?) If I do: ``` func Foo[V any](v V)bool { return v==v } ``` golang 1.19 reports: ``` invalid operation: v == v (incomparable types in type set) ``` There are two issu

Re: [go-nuts] Can I use the Golang logo on my site about Golang?

2023-01-18 Thread Rob Pike
golang.ru is a good name for such a site, but please keep in mind that the language itself is called just Go, as the logo itself should make clear. -rob On Thu, Jan 19, 2023 at 4:05 AM Ian Lance Taylor wrote: > On Wed, Jan 18, 2023 at 8:30 AM Василий Рузин wrote: > > > > Can I use the Golang

[go-nuts] Embedding shared libraries into gomobile archive

2023-01-18 Thread 'Vitaliy Vlasov' via golang-nuts
Hi all! I've got a golang project that uses cgo to interface with an external C library. So golang builds depend on that library's *.h and *.so files. Is there a way to tell `gomobile bind` to embed these external shared libraries into generated Android AAR or iOS Framework files? Thanks. --

Re: [go-nuts] Can I use the Golang logo on my site about Golang?

2023-01-18 Thread Ian Lance Taylor
On Wed, Jan 18, 2023 at 8:30 AM Василий Рузин wrote: > > Can I use the Golang logo on my site? > > My site will be dedicated to Golang. ( https://golang.ru ) > > The site will have documentation, articles, videos, vacancies and jobs, free > training. > > Perhaps in the future there will be paid t

[go-nuts] Can I use the Golang logo on my site about Golang?

2023-01-18 Thread Василий Рузин
Hello. Can I use the Golang logo on my site? My site will be dedicated to Golang. ( https://golang.ru ) The site will have documentation, articles, videos, vacancies and jobs, free training. Perhaps in the future there will be paid training, but I have not yet decided whether to do it or not.

[go-nuts] Re: httptest and gorilla/mux route variables

2023-01-18 Thread sanwal farooque
Kevin this is brilliant. It Works <3 <3 On Saturday, 4 December 2021 at 04:29:57 UTC+5 Kevin Mathew S wrote: > This works perfectly for me > > func newReq(method, path, body string, vars map[string]string) > *http.Request { > r := httptest.NewRequest(method, path, strings.NewReader(body)) > retu

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 you clarify by > saying