Re: [go-nuts] How to generalize parameters for a function

2023-03-14 Thread Kurtis Rader
On Tue, Mar 14, 2023 at 7:07 PM Frank Jüdes wrote: > Thank you very much Ian! > I am using a pointer to the map because i want to pass the map by > reference, not by value. > Those maps can become pretty large and are being handed down through a > couple of function calls and i don't want them

[go-nuts] Re: what the asyncPreempt happens in flamegraph mean?

2023-03-14 Thread Landon Cooper
Hi Cheng, I'm not sure I understand your question, but here's what little I know about the preempt function. runtime.asyncPreempt is used to implement asynchronous preemption. Basically, the go runtime scheduler occasionally suspends the execution of a goroutine to check if it has been running

[go-nuts] Re: what the asyncPreempt happens in flamegraph mean?

2023-03-14 Thread cheng dong
here is the go env ` GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/dongcheng/.cache/go-build" GOENV="/home/dongcheng/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPRIVATE=""

Re: [go-nuts] How to generalize parameters for a function

2023-03-14 Thread Frank Jüdes
Thank you very much Ian! I am using a pointer to the map because i want to pass the map by reference, not by value. Those maps can become pretty large and are being handed down through a couple of function calls and i don't want them to be copied over and over again. I read the document you

[go-nuts] Re: How to generalize parameters for a function

2023-03-14 Thread Landon Cooper
Hi Frank, the issue is that the compiler won't accept a map[string]float64 as a map[string]interface{} because they are defined as different types. It probably feels to you as though the code would work okay because you expect to take things out of the map, check their type and then use them

Re: [go-nuts] How to generalize parameters for a function

2023-03-14 Thread Ian Lance Taylor
On Tue, Mar 14, 2023 at 6:27 PM Frank Jüdes wrote: > > i still somewhat new with Go and need a little tutoring: I have to create > Excel files, using the excelize package and wrote a little function to store > data from a map[string]int64 into a column within the worksheet: > > // >

[go-nuts] How to generalize parameters for a function

2023-03-14 Thread Frank Jüdes
Hi Friends, i still somewhat new with Go and need a little tutoring: I have to create Excel files, using the *excelize* package and wrote a little function to store data from a map[string]int64 into a column within the worksheet: //

Re: [go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Kwaku Biney
Yeah this actually makes sense ``` On Wednesday, March 15, 2023 at 12:11:11 AM UTC Ian Lance Taylor wrote: > On Tue, Mar 14, 2023 at 3:47 PM Kwaku Biney wrote: > > > > i was digging in the rand package and came across NewSource(seed) in the > randpackage which creates a new source in case you

Re: [go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Ian Lance Taylor
On Tue, Mar 14, 2023 at 3:47 PM Kwaku Biney wrote: > > i was digging in the rand package and came across NewSource(seed) in the > randpackage which creates a new source in case you don't want the global > source set by the package. It returns a Source interface. For some reason, > there's a

[go-nuts] Why the extra call to `seed` in this situation?

2023-03-14 Thread Kwaku Biney
i was digging in the rand package and came across NewSource(seed) in the randpackage which creates a new source in case you don't want the global source set by the package. It returns a Source interface. For some reason, there's a seed method on the Source as well for which Rand implements,

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Brian Candler
Presumably you are looking at something like this: https://www.etsi.org/deliver/etsi_ts/129200_129299/129229/13.01.00_60/ts_129229v130100p.pdf *6.3.10 SIP-Authenticate AVP* *The SIP-Authenticate AVP is of type OctetString and contains specific parts of the data portion of the

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Brian Candler
On Tuesday, 14 March 2023 at 09:26:05 UTC Van Fury wrote: Am developing a server (diameter) which will response with an AVP SIP-Authenticate. In the specification " The SIP-Authenticate AVP is of type OctetString and It shall contain, binary encoded, the concatenation of the authentication

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Van Fury
Am developing a server (diameter) which will response with an AVP SIP-Authenticate. In the specification " The SIP-Authenticate AVP is of type OctetString and It shall contain, binary encoded, the concatenation of the authentication challenge RAND and the token AUTN" The RAND and the AUTN in this

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-14 Thread Marcello H
You can also use gob for that. Here are 2 functions from my library that can help. import "encoding/gob" /* encodeGob encodes a model to gob bytes. */ func encodeGob(data any) ([]byte, error) { var ( buf bytes.Buffer enc = gob.NewEncoder() // Will write to network. ) err := enc.Encode(data)

Re: [go-nuts] what's the most popular kafka library to use

2023-03-14 Thread Vasiliy Tolstov
I'm try all kafka libraries and my list: 1. github.com/twmb/franz-go/kgo - the best, no problems is around 1.5-2 years 2. github.com/segmentio/kafka-go (cool but have some errors 1.5 years ago, so i broke my production cluster with it) -- Vasiliy Tolstov, e-mail: