[go-nuts] Re: I made a CLI tool, and I'm curious about your ideas

2023-07-06 Thread long văn
Impressive now let's see paul allen's gnt Vào lúc 23:13:31 UTC+7 ngày Thứ Năm, 6 tháng 7, 2023, Alper Akca đã viết: > > > [image: gnt.png] > I am a beginner in Golang. I made a cli tool for creating a Go project. > You can easily create a new Go project using the 'gnt create projectName' >

[go-nuts] Re: Where are closure storing the captured variables ?

2023-07-06 Thread jake...@gmail.com
In addition to Axel's useful info, whenever you are interested in what escapes to the 'heap', it can be helpful to build with escape analyses output. Try using "go build -gcflags=-m". On Wednesday, July 5, 2023 at 8:35:52 PM UTC-4 chris...@meessen.net wrote: > Hello, > > Closure need space

Re: [go-nuts] CPU usage increasing day by day because of Cron

2023-07-06 Thread Steven Hartland
Your use of sync.WaitGroup looks strange. Typically you would expect to call wg.Add(1) before a goroutine is started, wg.Done() before it returns and wg.Wait() to ensure all goroutines have completed. This doesn't seem to be what you're doing. Consider restructuring to make best use of the

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread 'Axel Wagner' via golang-nuts
On Thu 6. Jul 2023 at 09:41, Henry wrote: > 'make' allocates the required memory. Does it? What about channels and maps? 'len' returns the length. What’s the “length” of a channel? What’s the “length” of a map? 'cap' returns the capacity. For maps? These questions are rhetorical, for

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread Brian Candler
In principle I agree with the sentiment, in the sense this is what you'd expect from other languages like Python. However, slices are fundamentally different to maps in Go. Map values contain a pointer to a mutable data structure (that's why you can't insert into a zero map - you have to

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread Henry
'make' allocates the required memory. 'len' returns the length. 'cap' returns the capacity. The underlying implementation may be different, but the concept is the same. There is no issue with those. It is common for a collection to have methods such as 'Add', 'Delete', and 'Clear'. The common

Re: [go-nuts] Why not return after calling http.Error()

2023-07-06 Thread Gurunandan Bhat
Thanks to everyone who reassured me. I considered posting a set of links from the most popular Golang tutorials that do not return after calling http.Error(), but then baulked In any case, thanks once again to all in this thread. Regards On Wed, Jul 5, 2023 at 4:13 AM ben...@gmail.com wrote:

Re: [go-nuts] how to close a child process after father process be killed

2023-07-06 Thread Peter Galbavy
Yes, setsid combined with cmd.Process.Release() works for me. My local / specific needs code is https://github.com/ITRS-Group/cordial/blob/ad18bfbfa44eff1b9b66408394dd83749da25bb1/pkg/process/process.go#L64 which works well for everything I have thrown at it (on Linux). On Wednesday, 5 July

Re: [go-nuts] Where are closure storing the captured variables ?

2023-07-06 Thread 'Axel Wagner' via golang-nuts
It depends a bit on escape analysis. I think the easiest way to reason about it is to say that they are stored in the `func` value. If the `func` value escapes, than so do the closed-over variables. If it doesn't (and the closed-over variables are not otherwise escaped) they don't. At least to an

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread 'Axel Wagner' via golang-nuts
Oh and FWIW: You are right (in my opinion) that the different things `clear` does are, well, different. But note that clear is not the only builtin for which that is the case. `make`, `len` and `cap` all do different things (to varying degrees) on maps, slices and channels. That's not necessarily

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread 'Axel Wagner' via golang-nuts
On Thu, Jul 6, 2023 at 7:49 AM Henry wrote: > So, if I get this right, clear on map will result in map length equals to > zero, but clear on slice is only a value-zeroing operation and the slice > length remains unchanged? That understanding is correct. > They seem like two different