Re: [go-nuts] How does golang handles DNS caching

2023-06-08 Thread Slawomir Pryczek
Probably 1. You're using connection pool in gorm 2. Gorm is using golang's connection pool 3. The connection gets cached/reused while domain's IP changes (as the address is same but ip changes and the change can't be easily detected) So the solution would probably be to do a lookup in a separate

Re: [go-nuts] [generics] instantiation of structs within generic functions

2023-06-08 Thread Jim Minter
On Thursday, 8 June 2023 at 22:23:51 UTC-6 Ian Lance Taylor wrote: On Thu, Jun 8, 2023 at 8:59 PM Jim Minter wrote: > > I'm rather confused by instantiation of structs in generic functions. I happen to be using go protobufs. Unlike with `json.Unmarshal`, `proto.Unmarshal` expects to receive a

Re: [go-nuts] [generics] instantiation of structs within generic functions

2023-06-08 Thread Ian Lance Taylor
On Thu, Jun 8, 2023 at 8:59 PM Jim Minter wrote: > > I'm rather confused by instantiation of structs in generic functions. I > happen to be using go protobufs. Unlike with `json.Unmarshal`, > `proto.Unmarshal` expects to receive a fully pre-instantiated struct to > unmarshal into. The non-ge

[go-nuts] [generics] instantiation of structs within generic functions

2023-06-08 Thread Jim Minter
Hi, I'm rather confused by instantiation of structs in generic functions. I happen to be using go protobufs. Unlike with `json.Unmarshal`, `proto.Unmarshal` expects to receive a fully pre-instantiated struct to unmarshal into. The non-generic case looks like this: var _ proto.Message = (*Fo

Re: [go-nuts] is running interactive or not

2023-06-08 Thread Rich
Thank you Cris and Kurtis -- For this project I am going with the switch option -- but I have other programs that I am going to replace the os.Getpid and os.Getppid trick with go-isatty. On Thursday, June 8, 2023 at 3:22:29 PM UTC-4 Chris Burkert wrote: > Hi, there are cases when this does no

Re: [go-nuts] is running interactive or not

2023-06-08 Thread Chris Burkert
Hi, there are cases when this does not work. I tend to use a flag like -batch or -noninteractive to trigger the correct behavior from within scripts. Less magic, more control. Rich schrieb am Do. 8. Juni 2023 um 20:19: > Hi, > > I have a program I am writing that stops and asks the user for inpu

Re: [go-nuts] is running interactive or not

2023-06-08 Thread Kurtis Rader
The easiest way to detect if your program is running interactively is to use https://github.com/mattn/go-isatty and test if stdin (fd 0) is connected to a terminal. The Elvish shell uses this function to handle both Unix and Windows: // IsATTY determines whether the given file is a terminal. func

[go-nuts] is running interactive or not

2023-06-08 Thread Rich
Hi, I have a program I am writing that stops and asks the user for input, in this case it's a passphrase used to encrypt output. I want the program to also be able to be used in a script, and if in a script use a predefined value as the passphrase. What I'd like to know is how to detect if r

Re: [go-nuts] Hard-to-explain race detector report

2023-06-08 Thread Brian Candler
> In this case however, what is reported is a concurrent write-after-read. Is that really a memory race? In general, it would be: if these accesses are not synchronized, there's a risk that the goroutines could slip relative to each other so that the write and read take place at the same time,

Re: [go-nuts] Hard-to-explain race detector report

2023-06-08 Thread burak serdar
On Wed, Jun 7, 2023 at 2:19 PM Sven Anderson wrote: > > > Caleb Spare schrieb am Mi. 7. Juni 2023 um 19:22: > >> On Wed, Jun 7, 2023 at 2:33 AM Sven Anderson wrote: >> > >> > That’s not only a read/write race, it’s also a write/write race. Every >> request to the server creates a new Go routine