Re: [go-nuts] CIDR from ip range

2022-11-08 Thread bar jan (janbar)
I used the new feature netip of Go1.18 to write code that applies both ipv4 and ipv6 https://go.dev/play/p/Ynx1liLAGs2 在2015年3月22日星期日 UTC+8 12:48:25 写道: > On Wednesday, March 18, 2015 at 7:33:54 AM UTC+1, Bakul Shah wrote: >> >> Rewriting this in Go is not difficult but you have to add some

[go-nuts] Re: checkptr reports error in lfstack_64bit.go

2022-11-08 Thread 'Keith Randall' via golang-nuts
Should be fixed by https://go-review.googlesource.com/c/go/+/448899 On Tuesday, November 8, 2022 at 4:34:00 PM UTC-8 Keith Randall wrote: > (Although normally lfstack nodes should not be heap allocated in the first > place?) > > > On Tuesday, November 8, 2022 at 4:32:11 PM UTC-8 Keith Randall w

[go-nuts] Re: checkptr reports error in lfstack_64bit.go

2022-11-08 Thread 'Keith Randall' via golang-nuts
(Although normally lfstack nodes should not be heap allocated in the first place?) On Tuesday, November 8, 2022 at 4:32:11 PM UTC-8 Keith Randall wrote: > I don't think checkptr is intended to be applied blindly inside the > runtime. The lfstack code is definitely doing things that checkptr wa

[go-nuts] Re: checkptr reports error in lfstack_64bit.go

2022-11-08 Thread 'Keith Randall' via golang-nuts
I don't think checkptr is intended to be applied blindly inside the runtime. The lfstack code is definitely doing things that checkptr was designed to catch and flag. Maybe the lfstack routines need a go:nocheckptr annotation? On Tuesday, November 8, 2022 at 11:21:30 AM UTC-8 David Pacheco wrote

Re: [go-nuts] Re: Unicode variable name error

2022-11-08 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-11-08 at 09:17 -0800, TheDiveO wrote: > I've always wondered how to deal with exported versus unexported > identifiers in scripts like Chinese? There is an issue for this https://go.dev/issue/22188 which discusses the approaches that are currently used with a view to making it easier.

Re: [go-nuts] Re: Unicode variable name error

2022-11-08 Thread TheDiveO
I've always wondered how to deal with exported versus unexported identifiers in scripts like Chinese? On Sunday, November 6, 2022 at 3:08:59 PM UTC+1 ba...@iitbombay.org wrote: > In Indic scripts in certain contexts you have to use a vowel sign for the > typography to make sense; you can’t use

Re: [go-nuts] Choosing ABI for a function

2022-11-08 Thread Ian Lance Taylor
On Tue, Nov 8, 2022 at 7:55 AM Aviram Hassan wrote: > > I see that some runtime functions have both `abi0` interface and > `ABIInternal`. > I was wondering what makes the compiler do so, and if I can make it do the > same for my defined functions? > A bit of a background - I'm doing a bit of a l

Re: [go-nuts] Why not sync.Mutex is designed as an interface

2022-11-08 Thread Ian Lance Taylor
On Tue, Nov 8, 2022 at 7:55 AM Xie Yuchen wrote: > > I checked with the issue about how to refer no-copy and the check of cmd/vet. > After checking, I'm curious that why not define mutex as an interface, as > interface always copy like a reference, which means users don't worry to copy > by val

[go-nuts] Re: Why not sync.Mutex is designed as an interface

2022-11-08 Thread TheDiveO
>From my limited experience, I notice two things: 1. I've rarely ever seen the need arise in my limited own experience to copy objects that would like to share their mutex. I would rather consider this to be most of the time a design issue, but I will be happy to stand corrected. Th

Re: [go-nuts] Picnic Senior Go Dev

2022-11-08 Thread Yamil Bracho
Hi, Giorgi and nice to meet you. I am interested in this position so enclosed my resume for your reference. Just let me know if you need any additional information. Best Regards, Yamil El mar, 8 nov 2022 a las 10:54, Giorgi Dalakishvili () escribió: > Hello Go Devs, I am Giorgi Tech recruiter a

[go-nuts] Why not sync.Mutex is designed as an interface

2022-11-08 Thread Xie Yuchen
I checked with the issue about how to refer no-copy and the check of cmd/vet. After checking, I'm curious that why not define mutex as an interface, as interface always copy like a reference, which means users don't worry to copy by value and cause an error. Design by the interface can always c

[go-nuts] Choosing ABI for a function

2022-11-08 Thread Aviram Hassan
Hi, I see that some runtime functions have both `abi0` interface and `ABIInternal`. I was wondering what makes the compiler do so, and if I can make it do the same for my defined functions? A bit of a background - I'm doing a bit of a lowlevel fun, and I want to hook Go functions using just Go c

[go-nuts] Picnic Senior Go Dev

2022-11-08 Thread Giorgi Dalakishvili
Hello Go Devs, I am Giorgi Tech recruiter at Picnic, Palo Alto / Ca based fast-growing app with 2 million users already. I want you to offer Golang Dev job, you can work remotely. If you have three years of experience in the Go language I want to offer you a really good working environment, a com

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread 'Mark' via golang-nuts
Thanks for your help and very interesting ideas. In the end I used this: type Set[T comparable] map[T]struct{} func New[T comparable](elements ...T) Set[T] { set := make(Set[T], len(elements)) for _, element := range elements { set[element] = struct{}{} } return set } fun

Re: [go-nuts] Goroutine to thread mapping

2022-11-08 Thread Robert Engels
To answer the rest of the question, since they are premptable they can be resumed on any thread. Go tries to use the same thread for performance but will issue memory barriers when it cannot. > On Nov 8, 2022, at 5:17 AM, peterGo wrote: > >  > piotr, > > Goroutines are now asynchronously pr

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread roger peppe
If you're sure that T is an int or a string, then why not constrain it as such? https://go.dev/play/p/1kT6EacMHco You could go further and constrain it to allow any type with ordering defined: https://go.dev/play/p/il5koj1RPkh If you want to allow any kind of comparable key in your set, one could

Re: [go-nuts] Goroutine to thread mapping

2022-11-08 Thread peterGo
piotr, Goroutines are now asynchronously preemptible. As a result, loops without function calls no longer potentially deadlock the scheduler or significantly delay garbage collection. February 2020, https://go.dev/doc/go1.14#runtime peter On Tuesday, November 8, 2022 at 3:31:25 AM UTC-5 pio

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 10:56 AM 'Mark' via golang-nuts wrote: > // Want to sort by T < T // > elements := make([]string, 0, len(me)) > for element := range me { > elements = append(elements, fmt.Sprintf("%#v", element)) > } > sort.Strings(elements) >

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread 'Mark' via golang-nuts
I see that your example works, but I can't see how to adapt it to my use case. type Set[T comparable] map[T]struct{} func New[T comparable](elements ...T) Set[T] { set := make(Set[T], len(elements)) for _, element := range elements { set[element] = struct{}{} } return set

Re: [go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread Jan Mercl
On Tue, Nov 8, 2022 at 9:53 AM 'Mark' via golang-nuts wrote: > Given a function: > > func F[T comparable](a T) { > } > > is it possible to check T's type inside F? > > My use case is that I have a function with signature G[T comparable](x []T) > and inside G I want to sort the elements in slice

[go-nuts] Is it possible to switch on type T in a generic function?

2022-11-08 Thread 'Mark' via golang-nuts
Given a function: func F[T comparable](a T) { } is it possible to check T's type inside F? My use case is that I have a function with signature G[T comparable](x []T) and inside G I want to sort the elements in slice x where T could be int or string. This arises in a tiny generic set module I

Re: [go-nuts] Goroutine to thread mapping

2022-11-08 Thread Piotr Wyderski
I am fine with affinity changes during, say, a mutex or channel operation. But does (or merely can) Go preempt the execution of leaf assembly functions, basically re-creating threads in user space? Or is the currently assigned thread mapping locked until the function decides to return, as coope

Re: [go-nuts] Goroutine to thread mapping

2022-11-08 Thread Piotr Wyderski
I mean the Plan 9 assembler. Also assume the function is a leaf function, just a long one. Can such a function be preempted by Go runtime and re-assigned to another thread or can the reassignment happen only cooperatively, in a number of roughly predictable selected places? poniedziałek, 7 lis