Re: [go-nuts] epoll: why write 1 byte to the pipe in netpollBreak() and read up to 16 bytes in netpoll()?

2023-08-14 Thread metronome
Hi Ian, Thanks for clarifying, yes it's no harm to leave the code untouched. On Tuesday, August 15, 2023 at 3:21:57 AM UTC+8 Ian Lance Taylor wrote: > On Mon, Aug 14, 2023 at 11:28 AM metronome wrote: > > > > >> If several different goroutines decide to wake up the polling > > >> goroutine

[go-nuts] Re: slog.GroupValue could potentially not make a new slice

2023-08-14 Thread Diego Augusto Molina
Sorry, just thought it could also use clear to start getting accostumed :) // GroupValue returns a new Value for a list of Attrs. // The caller must not subsequently mutate the argument slice. func GroupValue(as ...Attr) Value { // Remove empty groups. // It is simpler overall to do

[go-nuts] slog.GroupValue could potentially not make a new slice

2023-08-14 Thread Diego Augusto Molina
Hello everyone, thank you for reading. I'm looking at the code of slog.GroupValue (https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/log/slog/value.go;l=171) and was wondering if we could benefit from reusing the same slice like this: // GroupValue returns a new Value for a list of

Re: [go-nuts] Generic zero value for compiler optimization

2023-08-14 Thread Diego Augusto Molina
Thank you very much, that's actually what I was looking for. On Monday, 14 August 2023 at 13:57:35 UTC-3 Axel Wagner wrote: > You might be interested in https://github.com/golang/go/issues/61372 > > On Mon, Aug 14, 2023 at 3:52 PM Diego Augusto Molina < > diegoaugu...@gmail.com> wrote: > >> Hi,

Re: [go-nuts] cgo pam module signal handling

2023-08-14 Thread Chandrasekhar R
The scenario is: 1) sudo starts and sets up a signal handler for SIGCHLD 2) pam modules gets loaded 3) Go gets initialized and sets the SA_ONSTACK flag specifically by calling rt_sigaction with a pointer to the existing signal handler in *sa_handler * field*.* 4) Sudo initialized a new signal

Re: [go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-14 Thread David Finkel
On Mon, Aug 14, 2023 at 4:54 PM Pablo Caballero wrote: > I started working on a Golang project (from my work). The following > pattern makes the company configured linter to complain with: > sloppyReassign: re-assignment to `err` can be replaced with `err := > myFunc2()` (gocritic) > > func

[go-nuts] I need confirmation about whether I'm in front of a linter false positive.

2023-08-14 Thread Pablo Caballero
I started working on a Golang project (from my work). The following pattern makes the company configured linter to complain with: sloppyReassign: re-assignment to `err` can be replaced with `err := myFunc2()` (gocritic) func myFunc() error { ... blah, err := getBlah() if err != nil { return

Re: [go-nuts] epoll: why write 1 byte to the pipe in netpollBreak() and read up to 16 bytes in netpoll()?

2023-08-14 Thread Ian Lance Taylor
On Mon, Aug 14, 2023 at 11:28 AM metronome wrote: > > >> If several different goroutines decide to wake up the polling > >> goroutine before the polling goroutine wakes up, they will each write > >> a single byte > > Wondering, with the introduction of "netpollWakeSig", does it still hold >

Re: [go-nuts] cgo pam module signal handling

2023-08-14 Thread Ian Lance Taylor
On Mon, Aug 14, 2023 at 12:02 PM Chandrasekhar R wrote: > > My understanding currently is sudo sets up a signal handler in pre_exec and > another signal handler later on which is tied into its main event loop. > Go gets initialized when the pre_exec signal handler is used and it adds >

Re: [go-nuts] cgo pam module signal handling

2023-08-14 Thread Chandrasekhar R
My understanding currently is sudo sets up a signal handler in pre_exec and another signal handler later on which is tied into its main event loop. Go gets initialized when the pre_exec signal handler is used and it adds rt_sigaction(SIGCHLD..) with the SA_ONSTACK flag as mentioned here

Re: [go-nuts] epoll: why write 1 byte to the pipe in netpollBreak() and read up to 16 bytes in netpoll()?

2023-08-14 Thread metronome
>> If several different goroutines decide to wake up the polling >> goroutine before the polling goroutine wakes up, they will each write >> a single byte Wondering, with the introduction of "netpollWakeSig", does it still hold true? Thanks. On Tuesday, July 11, 2023 at 9:00:36 AM UTC+8 Ian

Re: [go-nuts] Generic zero value for compiler optimization

2023-08-14 Thread 'Axel Wagner' via golang-nuts
You might be interested in https://github.com/golang/go/issues/61372 On Mon, Aug 14, 2023 at 3:52 PM Diego Augusto Molina < diegoaugustomol...@gmail.com> wrote: > Hi, thank you for reading. Whenever I need to use a zero value for a > generic type in a func I do something like the following: > >

[go-nuts] Generic zero value for compiler optimization

2023-08-14 Thread Diego Augusto Molina
Hi, thank you for reading. Whenever I need to use a zero value for a generic type in a func I do something like the following: func SetZero[T any](pt *T) T { var zeroT T *pt = zeroT } That's all good, but I wonder how, if possible, it could be proved to the compiler that zeroT is the

Re: [go-nuts] Re: slog's use of runtime.Callers() with a skip

2023-08-14 Thread 'Shaun Crampton' via golang-nuts
> > Do you have any evidence to the contrary? Only that when Go 1.12 dropped, our similar function stopped working and that reducing the skip seemed to do the trick. The symptom was that our function would see an assembly file as the caller, which I interpreted to mean that we'd skipped too

[go-nuts] Re: What does `shallow clone` mean?

2023-08-14 Thread Brian Candler
On Friday, 11 August 2023 at 17:56:01 UTC+1 Shinya Sakae wrote: I often hear the term `shallow copy', but I don't know what `shallow clone` means. Don't worry: they are the same thing. When cloning a map, the keys and values are set using ordinary assignment, as the description says. It