Re: [go-nuts] How to convert a net.Addr into a netip.AddrPort ?

2023-12-25 Thread christoph...@gmail.com
and client code > > On Dec 24, 2023, at 11:05 AM, christoph...@gmail.com < > christoph...@gmail.com> wrote: > >  > > Hello, > > I'm developping a UDP client server program. Everything is clear on the > server side. > > I'm just a bit confused with the client

[go-nuts] How to convert a net.Addr into a netip.AddrPort ?

2023-12-24 Thread christoph...@gmail.com
Hello, I'm developping a UDP client server program. Everything is clear on the server side. I'm just a bit confused with the client side. In C we can specify the network address and set the port to 0 so that a free port is picked. Apparently we can't do that with the net API. The client

[go-nuts] Encrypting a small secret using curve25519

2023-09-20 Thread christoph...@gmail.com
Hello, I noticed that the go standard library only support ed25519 signing (https://pkg.go.dev/crypto/ed25519@go1.21.1). I would need to encrypt a small secret with the public key of the receiver so that he is the only one able to decrypt it with its private key. The small secret would

[go-nuts] Interface() method of reflect.Value sometimes allocates, sometimes not

2023-06-26 Thread christoph...@gmail.com
I'm implementing a value encoder similar to gob. While bench-marking my code against gob, I noticed some unexpected memory allocations with a particular type of data. See this minimal code example in the go playground https://go.dev/play/p/4rm-kCtD274 There is a simple function foo()

[go-nuts] Re: delve crashes in presence of a circular reference variable

2023-06-23 Thread christoph...@gmail.com
I should have added that the debugger crashes when it reaches a break point after the p = instruction or steps over this instruction. It doesn't crash when there is no break point. Le vendredi 23 juin 2023 à 10:38:32 UTC+2, christoph...@gmail.com a écrit : > Here is the minimal example c

[go-nuts] delve crashes in presence of a circular reference variable

2023-06-23 Thread christoph...@gmail.com
Here is the minimal example code causing delve 1.20.2 to crash with a stack overflow func TestExample(t *testing.T) { type pptr *pptr var p pptr p = t.Error("hello") } Here is the stack trace goroutine 6 [running]: runtime.deductAssistCredit(0x108?)

[go-nuts] Why is reflect.CanAddr() returning false in this case ?

2023-06-22 Thread christoph...@gmail.com
I'm trying to get the uintptr address of a value p for which I have the reflect.Value so that I can compare it with the value obtained with v.Pointer() when p is a pointer. Here is a simple recursive pointer example code showing what happens: https://go.dev/play/p/pST8DierbXS It is a pointer

[go-nuts] Unexpected circular type definition limitation

2023-06-15 Thread christoph...@gmail.com
It is possible to define two structures globally with mutual type dependency as this: type A struct { B []B } type B struct { A A[] } but I just noticed that we can't do that inside a function: func Foo() { type A struct { B []B } type B struct { A A[]

[go-nuts] How to detect a reflect.Value of nil ?

2023-06-01 Thread christoph...@gmail.com
I have a method that receives a reflect.Value as input argument. When the method is given the argument reflect.ValueOf(nil), the methods Type(), IsNil(), or IsZero() panic. For instance, when I call the method IsZero() I see the panic message "panic: reflect: call of reflect.Value.IsZero on

[go-nuts] Re: Installing a package with an associated command

2022-05-25 Thread christoph...@gmail.com
On Wednesday, 25 May 2022 at 08:13:58 UTC+2 christoph...@gmail.com wrote: > >> I have a small package (https://github.com/chmike/clog) that also >> contains a command in the cmd subdirectory (clogClr). How do I install >> the clog package and the command ? >> >&

[go-nuts] Installing a package with an associated command

2022-05-25 Thread christoph...@gmail.com
I have a small package (https://github.com/chmike/clog) that also contains a command in the cmd subdirectory (clogClr). How do I install the clog package and the command ? When I execute "go install github.com/chmike/clog@latest" I get the error message that it is not a main package. When I

Re: [go-nuts] Re: Can’t view golang source when clicking on method name in a pkg.go.dev

2022-04-26 Thread christoph...@gmail.com
Thank you very much. I disabled the DuckDuckGo Privacy Essentials extension and it now works. I also noticed that when I do a duckduckgo search for golang packages, that the pkg.go.dev pages are low ranked if present.

[go-nuts] Re: Can’t view golang source when clicking on method name in a pkg.go.dev

2022-04-26 Thread christoph...@gmail.com
This is a screen capture of what I see https://imgur.com/a/nuBfZeY Le mardi 26 avril 2022 à 09:37:38 UTC+2, christoph...@gmail.com a écrit : > Sorry, my message needs a clarification. The page > https://cs.opensource.google/go/go/+/go1.18.1:src/encoding/json/stream.go;l=49 > > doe

[go-nuts] Re: Can’t view golang source when clicking on method name in a pkg.go.dev

2022-04-26 Thread christoph...@gmail.com
se. Le mardi 26 avril 2022 à 09:16:06 UTC+2, christoph...@gmail.com a écrit : > I’m redirected to this page > https://cs.opensource.google/go/go/+/go1.18.1:src/encoding/json/stream.go;l=49 > > when I click on the Decode method in the web page > https://pkg.go.

[go-nuts] Can’t view golang source when clicking on method name in a pkg.go.dev

2022-04-26 Thread christoph...@gmail.com
I’m redirected to this page https://cs.opensource.google/go/go/+/go1.18.1:src/encoding/json/stream.go;l=49 when I click on the Decode method in the web page https://pkg.go.dev/encoding/json#Decoder. Is this a transient problem or is the code not open source anymore ? -- You received this

[go-nuts] How to format hour in 24h format without leading 0 ?

2022-04-25 Thread christoph...@gmail.com
I need to format a time stamp hours in 24h format but without leading 0. This means 7 -> "7" and 17 -> "17". For 24h values, the only formatting key value provided and documented is 15. But this produces "7" -> "07" and 17 -> "17" which is not what I need. According to

[go-nuts] Re: When will the official encoding/json package support parsing json5?

2022-03-20 Thread christoph...@gmail.com
You might want to try qjson that I wrote a year ago (https://github.com/qjson). It's basically just one function that converts qjson text into json. Qjson is inspired by hjson, but extend it in many ways. It is convenient for config files. Maybe I extend it a bit too far by supporting

Re: [go-nuts] Possible float64 precision problem

2022-03-10 Thread christoph...@gmail.com
erse engineering and I think it will be a good exercise. > > Thank you! > > Best > > Pablo > > On Wed, Mar 9, 2022, 4:39 PM 'Dan Kortschak' via golang-nuts < > golan...@googlegroups.com> wrote: > >> On Wed, 2022-03-09 at 03:37 -0800, christoph...@gmai

[go-nuts] Re: Possible float64 precision problem

2022-03-09 Thread christoph...@gmail.com
A simple C and Go program to demonstrate the problem doesn't show any difference between C and Go. It's thus most probably a difference in the code that I must investigate. Sorry for the noise. Le mercredi 9 mars 2022 à 12:37:10 UTC+1, christoph...@gmail.com a écrit : > I'm translat

[go-nuts] Possible float64 precision problem

2022-03-09 Thread christoph...@gmail.com
I'm translating a scientific C program into Go that is doing some 64bit floating point operations. In this process I check that the same input yields the same output. Unfortunately they don't yield the same result, though the computation is simple. It is as follow. I receive a 64bit integer

[go-nuts] New edition of the Go Programming Language comming soon ?

2022-02-13 Thread christoph...@gmail.com
Hello Go friends, is there a new edition of the "Go Programming Language" book to be published soon ? It is quite old now and there have been a few changes to Go since then. Go.mod and generics. I was considering buying it, but if a new edition comes out in a few months, it would be wasted

[go-nuts] Re: Unable to handle duplicate cookies

2021-09-23 Thread christoph...@gmail.com
at should > be pretty easy > > On Thursday, September 23, 2021 at 10:02:34 AM UTC+2 > christoph...@gmail.com wrote: > >> I implemented a simple web site with a csrf secure cookie that is reset >> for each page showing a form. I assumed that simply setting the cookie with &g

[go-nuts] Unable to handle duplicate cookies

2021-09-23 Thread christoph...@gmail.com
I implemented a simple web site with a csrf secure cookie that is reset for each page showing a form. I assumed that simply setting the cookie with the same name and a new value would override the cookie in the client browser. This assumption is correct as long as the url of the page is the

[go-nuts] derive encoder/decoder from std json encoder/decoder ?

2021-07-08 Thread christoph...@gmail.com
I need to write a binary encoder/decoder very similar to the std JSON encoder/decoder. I would like to reuse 80% of the JSON encoder/decoder code and adapt it to support my binary encoding. Is this allowed and at which condition ? Would it be possible to publish my code on github with an

Re: [go-nuts] Computing a hash over a uintptr ?

2021-06-04 Thread christoph...@gmail.com
t; golan...@googlegroups.com> wrote: > > > >  > > On Thu, Jun 3, 2021 at 4:19 PM christoph...@gmail.com < > christoph...@gmail.com> wrote: > >> > >> The documentation doesn’t specify that we can cast an uintptr into a > uint64. > > >

[go-nuts] Computing a hash over a uintptr ?

2021-06-03 Thread christoph...@gmail.com
The documentation specifies that a pointer can be cast into a uintptr integer. I assume that the uintptr is ignored by the garbage collector. I would like to compute a hash over the uintptr. How do I achieve that ? The documentation doesn’t specify that we can cast an uintptr into a uint64.

[go-nuts] Security issue in

2021-05-07 Thread christoph...@gmail.com
I just became aware of a security problem in the package https://github.com/satori/go.uuid through this reddit thread : https://www.reddit.com/r/golang/comments/n6bnsh/cve20213538_issued_for_latest_release_of/?utm_source=share_medium=ios_app_name=iossmf The issue for

[go-nuts] Re: How to manage replace directives in go.mod files when code versioning ?

2021-04-27 Thread christoph...@gmail.com
her modules. See Minimal > version selection <https://golang.org/ref/mod#minimal-version-selection> for > details."? > > You can find it here: https://golang.org/ref/mod#go-mod-file-replace > > On Tuesday, April 27, 2021 at 7:23:52 AM UTC+2 christoph...@gmail.com &g

Re: [go-nuts] rationale for math.Max(1, math.NaN()) => math.NaN()?

2021-04-27 Thread christoph...@gmail.com
It seam that C is wrong on this one and Go is right. The rationale is that a NaN must propagate through operations so that we can detect problems (avoid silent NaNs). See https://en.wikipedia.org/wiki/NaN Thus any operation involving a NaN must return an NaN and this includes Max and Min.

[go-nuts] How to manage replace directives in go.mod files when code versioning ?

2021-04-26 Thread christoph...@gmail.com
When debugging or testing we may need to add a replace directive in the go.mod file. This change intended to be local only may interfere with code versioning. The replace directive may be accidentally committed and published. What is the proper way to manage replace directives when it comes to

[go-nuts] Big variations in benchmarking results ?

2021-04-07 Thread christoph...@gmail.com
Hello, I'm benchmarking some code with my mac book air. The code is only computation and writing in a preallocated slice. I see big variations in the ns/op (e.g. 5000 to 8000). I disabled the turbo boost but the variations are still there. To verify I tried the code benchmarking on an Ubuntu

[go-nuts] Is the Go png encoder performing gamma correction ?

2021-03-30 Thread christoph...@gmail.com
It is unspecified in the documentation if the png encoder is performing gamma correction. I thus assume that it is not performing gamma correction. Is this assumption correct ? According to wikipedia, jpg images are gamma encoded. What is the status of png images ? It seam relevant for

Re: [go-nuts] Casting int to bool and the reverse for bit hacking ?

2020-11-22 Thread christoph...@gmail.com
> > I don't see branching in relevant parts. v == v1 || v == v2 will of > course branch because || is a condition. > > Does that answer your question or maybe I am missing something? > > пт, 20 нояб. 2020 г. в 11:27, christoph...@gmail.com > : > > > > Go has a strict

[go-nuts] Re: Carting int to bool and the reverse for bit hacking ?

2020-11-21 Thread christoph...@gmail.com
Thank you for the responses. Unfortunately, they all comment on the given use case. The real question is if we should add a function in math/bits that performs the operation. The function would be func notZero(x int) int { if x == 0 { return 0 } return 1 } Regarding code

[go-nuts] Carting int to bool and the reverse for bit hacking ?

2020-11-20 Thread christoph...@gmail.com
Go has a strict type separation between int and bool. For a normal usage this is OK. I guess it also ease assembly portability because there is not always a machine instruction to do so. For bit hacking, this is an unfortunate limitation. A handy feature of bool <-> int conversion is that

[go-nuts] Re: Why key.PublicKey.Equal(key.PublicKey) return false ?

2020-10-27 Thread christoph...@gmail.com
My formulation was not clear. The test fails, and it reports a key mismatch. Le mardi 27 octobre 2020 à 16:21:05 UTC+1, christoph...@gmail.com a écrit : > I have the following test that fails reporting a key mismatch. > > func TestKeyEqual(t *testing.T) { > key, err := rsa

[go-nuts] Why key.PublicKey.Equal(key.PublicKey) return false ?

2020-10-27 Thread christoph...@gmail.com
I have the following test that fails reporting a key mismatch. func TestKeyEqual(t *testing.T) { key, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { t.Fatal("failed generating private key: ", err) } if !key.PublicKey.Equal(key.PublicKey) {

[go-nuts] Re: Generics and parentheses

2020-07-20 Thread christoph...@gmail.com
I would like to insist on considering the D syntax using the ! for generics instantiation. The first time I saw it, I was puzzled and found it unpleasant. But this is just because it is unfamiliar and not intuitive. Once I got used to it, I found it much simple than the C++ templates. In fact