[go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread changkun
Hi golang-nuts, I would like to call a C function from Go and get notified about the execution status in Go, say a goroutine wait until the C function finally made some progress. Initially, I thought about passing a channel to C but the cgo document does not say anything about that: Later, I a

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-15 Thread roger peppe
Thanks for bringing this up. It surprised me too until I realised what was going on. The issue here is about the default precision that you're getting for those big.Float values. When you use big.NewFloat, the precision you get is exactly the same as that of a base64 float (53 bits). When you use

Re: [go-nuts] about -buildmode c-shared

2021-02-15 Thread Frédéric De Jaeger
On Saturday, February 13, 2021 at 4:21:34 PM UTC+1 Ian Lance Taylor wrote: > > > > I was naively assuming that the unloading issue is easy to tackle when > the runtime is not shared between .so. Is it true ? > > No. The current Go runtime has no ability to shut down all > goroutines. If any g

Re: [go-nuts] Error handling

2021-02-15 Thread Michael MacInnis
> > Go helps with that. Even team's proposal was finally retracted: > https://github.com/golang/go/issues/32437 Discussion there is lengthy, > but worth > reading to sense why wider community considers "boilerplate" as asset. > Thanks, I did follow the try proposal and the earlier check/handle

Re: [go-nuts] big.Float.Cmp does not work as expected

2021-02-15 Thread Jesper Louis Andersen
On Sun, Feb 14, 2021 at 9:20 PM Santhosh Kumar T wrote: > I created: > one instance using big.NewFloat function > another instance using big.Float.SetString method > > Adding to this: Generally, comparing FP values for equality can give results you don't expect due to the way numerics fo

Re: [go-nuts] Error handling

2021-02-15 Thread Volker Dobler
I think there is strong consensus, that the current style of error handling is currently the best option. Nobody has been able to come up with something better (really better, not just more comfortable while ignoring hefty drawbacks). It is true that a loud minority seems to miss exceptions to

[go-nuts] [ANN] Hare - a nimble little DBMS written in Go.

2021-02-15 Thread Jamey Cribbs
After working on this package off and on for a long time, I've finally decided to set it free into the wild. Hare is a pure Go database management system that stores each table as a text file of line-delimited JSON. Each line of JSON represents a record. It is a good fit for applications that

Re: [go-nuts] Error handling

2021-02-15 Thread Arnaud Delobelle
I do sometimes do something similar, but without the check() function. The exit points are explicit, it is guaranteed that errors will be wrapped. func do(name string) (err error) { defer PWrapf(&err, "do(%s)", name) s, err := works(name); if err != nil { r

Re: [go-nuts] [ANN] Hare - a nimble little DBMS written in Go.

2021-02-15 Thread Artur Vianna
Looks very cool! Seems like a nice fit for persistent storage in games On Mon, 15 Feb 2021, 14:37 Jamey Cribbs, wrote: > After working on this package off and on for a long time, I've finally > decided to set it free into the wild. > > Hare is a pure Go database management system that stores eac

Re: [go-nuts] Error handling

2021-02-15 Thread robert engels
And I will tell you that after working with error returns and exceptions, exceptions are superior - but much depends on the complexity of the system. For small system level tools that are pieced together via pipes, C error handling is fine - because the process serves as the exception handling p

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread Ian Lance Taylor
On Mon, Feb 15, 2021 at 1:32 AM changkun wrote: > > I would like to call a C function from Go and get notified about the > execution status in Go, say a goroutine wait until the C function finally > made some progress. > Initially, I thought about passing a channel to C but the cgo document does

Re: [go-nuts] about -buildmode c-shared

2021-02-15 Thread Ian Lance Taylor
On Mon, Feb 15, 2021 at 6:51 AM Frédéric De Jaeger wrote: > > On Saturday, February 13, 2021 at 4:21:34 PM UTC+1 Ian Lance Taylor wrote: >> >> >> >> > I was naively assuming that the unloading issue is easy to tackle when the >> > runtime is not shared between .so. Is it true ? >> >> No. The curr

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread changkun
Hi Ian, Thanks for the hint, but I have some follow-up questions: > Even if there were a way to do this, an atomic variable is not a good > synchronization mechanism, because the other side has to poll the > variable. Indeed, it the other side will be a spin loop to poll the atomic variable,

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread Ian Lance Taylor
On Mon, Feb 15, 2021 at 12:39 PM changkun wrote: > > Thanks for the hint, but I have some follow-up questions: > >> >> Even if there were a way to do this, an atomic variable is not a good >> synchronization mechanism, because the other side has to poll the >> variable. > > Indeed, it the other si

Re: [go-nuts] How to use atomic_int in cgo?

2021-02-15 Thread Devon H. O'Dell
Forgot to reply to the list. Oops. Sorry for the second delivery, Changkun. On Mon, Feb 15, 2021 at 12:39 changkun wrote: > Hi Ian, > > Thanks for the hint, but I have some follow-up questions: > > >> Even if there were a way to do this, an atomic variable is not a good >> synchronization mechan

Re: [go-nuts] [ANN] github.com/jba/codec, a fast encoder for Go

2021-02-15 Thread Jonathan Amsterdam
I changed the encoding so that the previous generated code is no longer necessary. Encoded data now carries all the information needed to decode struct fields correctly, even if fields have been added and reordered. On Sunday, January 24, 2021 at 8:29:58 AM UTC-5 Jonathan Amsterdam wrote: > Th

[go-nuts] type checking custom interface{} is not working as expected

2021-02-15 Thread Santhosh Kumar T
I have a function call nextRow which returns []interface{} i want to add support for json, since json value can be string, number which conflicts with native types, i used following: type Json interface{} and returning json values as: return Json(v) but in type checking it fails. i extra