Re: [go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread Jesper Louis Andersen
It depends. If you know everything you have done is safely on disk somewhere, or you have a stateless system, you can end the application by a panic. However, in the event your program or requirements change, it can be desirable to mix in lifecycle management early on. This includes graceful

[go-nuts] How to print address of structure's member using gdb

2023-04-12 Thread 'Srinivas Pokala' via golang-nuts
Hi All, How to print content of structure's one of member using gdb if we have address of structure. Ex: type Sar struct { name string clp uintptr number int } var x uintptr let's say x pointing to address of structure sar, How to print member data clp in gdb. I tried (gdb) print

[go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread Frank
Hi Gophers, So I've run into a situation where my code would run for a rather long time (10minutes - ~1 hour). And I want to cancel it halfway sometimes. I know I can use channel/context can check for channel message to return early. But this requires explicitly checking for channel status and

[go-nuts] Re: Generic Wrappers that do reflection on Initialization

2023-04-12 Thread Peter Müller
Update: I've found something similar in pkgsite https://github.com/golang/pkgsite/blob/beceacdece62d95d6dc41a9b5f09da7b2a021020/internal/database/reflect.go so I now assume it's not as far fetched as I thought until now. Peter Müller schrieb am Freitag, 3. März 2023 um 16:53:07 UTC+1: >

Re: [go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread Ian Lance Taylor
On Wed, Apr 12, 2023 at 7:44 AM burak serdar wrote: > > There are ways to reduce the boilerplate code. For instance: > > func LongTask(ctx context.Context) { >canceled:=func() bool { > select { > case <-ctx.Done(): return true > default: > } > return false >

[go-nuts] Go to wasm : `go::debug` has not been defined

2023-04-12 Thread Stan Srednyak
I compiled a Go program to wasm using GOOS=js GOARCH=wasm go build -o main.wasm It gives me the following error Error: failed to run main module `main.wasm` Caused by: 0: failed to instantiate "main.wasm" 1: unknown import: `go::debug` has not been defined How to fix this? -- You

Re: [go-nuts] Immediately Cancel Goroutine?

2023-04-12 Thread burak serdar
On Wed, Apr 12, 2023 at 7:29 AM Frank wrote: > Hi Gophers, > > So I've run into a situation where my code would run for a rather long > time (10minutes - ~1 hour). And I want to cancel it halfway sometimes. I > know I can use channel/context can check for channel message to return > early. But

[go-nuts] Re: [Contribution] Go_Updater shellscripting (GNU/Linux or WSL)

2023-04-12 Thread Walddys Emmanuel Dorrejo Céspedes
Hello, the script does that, i created in base of go.dev recommendation, it will not remove the folder, but delete all the content. El martes, 11 de abril de 2023 a la(s) 10:31:45 UTC-4, Brian Candler escribió: > Something to consider: if you untar over an existing installation, then > it's

Re: [go-nuts] Map of types?

2023-04-12 Thread Martin Schnabel
Hi Bèrto, as you said, you cannot put a type directly into a map. However you can use package reflect to get type reflection information, that you can put into a map. But in this case I would simple use a map of constructor functions that have a common interface. Like this