[go-nuts] gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Amit Lavon
Hi gophers, Demonstration: https://play.golang.org/p/AY-fVWiOrFd I am reading raw bytes from a gzip input. I found that it only reads up to chunks of 2^15 even though there is more data to be read. Is that the intended behavior? I expected whatever internal buffering it may have to be invisibl

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Amit Lavon
Thank you!! io.ReadFull is just what I needed (and what I actually expected from Reader.Read). Why would I ever use Reader.Read rather than ReadFull? On Tue, Jun 9, 2020 at 6:11 PM Brian Candler wrote: > There is io.ReadFull if you want to > read as much as

Re: [go-nuts] Re: gzip.Reader.Read does not fill the given buffer

2020-06-09 Thread Amit Lavon
Interesting points. So I guess ReadFull can be suitable for the consuming end of those bytes. Thank you! On Tue, Jun 9, 2020 at 11:40 PM Brian Candler wrote: > On Tuesday, 9 June 2020 17:53:07 UTC+1, Amit Lavon wrote: >> >> Why would I ever use Reader.Read rather than ReadFull?

[go-nuts] Slice to array using the same buffer?

2021-02-01 Thread Amit Lavon
I know it's possible to create a slice variable from an array with the [:] syntax, and it points to the same underlying buffer. Can one do the opposite? Given a slice, create an array variable based on the same buffer? Amit -- You received this message because you are subscribed to the Google

Re: [go-nuts] Slice to array using the same buffer?

2021-02-01 Thread Amit Lavon
Thanks! Something to look forward to. On Mon, Feb 1, 2021 at 2:43 PM Axel Wagner wrote: > Not yet, but probably an go 1.17: https://github.com/golang/go/issues/395 > > On Mon, Feb 1, 2021 at 1:38 PM Amit Lavon wrote: > >> I know it's possible to create a slice variable

[go-nuts] Naming convention for a struct that writes other structs to an io.Writer?

2021-02-25 Thread Amit Lavon
Writer? Encoder? Putter? I am creating a library for writing certain data objects (hence MyStruct) to an io.Writer. I was trying to find how Go's standard library typically names interfaces like that so that I could stick to the conventional naming. Seems that the JSON

[go-nuts] Calling Go from Python

2021-04-06 Thread Amit Lavon
Hi, A cheat-sheet I wrote for myself evolved into a full tutorial on calling Go directly from Python using ctypes and dll's, so I am happy to share it with the community. It starts from the very basics and covers how to handle arrays, strings and objects in

[go-nuts] Re: Calling Go from Python

2021-04-07 Thread Amit Lavon
Thanks! Gopy seemed promising back when I started exploring this topic, but I had some issues getting it to work, especially on Windows. It may have gotten better by now. Anyway I agree it's beneficial to have both approaches available so I am happy to see gopy grow as well. On Wednesday, April

[go-nuts] Generating go code using go templates

2021-09-07 Thread Amit Lavon
Hi gophers, I wrote https://github.com/fluhus/goat for generating go code in my projects. I hope it can help you too. It's a minimal tool that takes a text/template template as input, runs it on the given parameters and gofmt's the output. You can also use it

[go-nuts] Why is my package doc too long on pkg.go.dev?

2021-09-10 Thread Amit Lavon
In my repo overview page , I would like the doc column to only show the first sentence. Here specifically "Package fasta handles fasta I/O". See screenshots below. How can I achieve that? Is there documentation regarding how package docs get rendered o

[go-nuts] Can generics save virtual function calls?

2022-04-05 Thread Amit Lavon
Hi gophers, When we use an interface as a type parameter, does it mean that calls to that interface will be replaced with calls to the concrete type? To demonstrate, consider https://go.dev/play/p/j4N8G_n-3uG . Will the compiler create a static call to MyDoer.Do instead of a virtual call to Doe

Re: [go-nuts] Can generics save virtual function calls?

2022-04-06 Thread Amit Lavon
Thank you! On Tuesday, April 5, 2022 at 10:05:40 PM UTC+3 Ian Lance Taylor wrote: > On Tue, Apr 5, 2022 at 11:05 AM Amit Lavon wrote: > > > > When we use an interface as a type parameter, does it mean that calls to > that interface will be replaced with calls to the concret

[go-nuts] biostuff: computational biology packages for Go

2022-05-09 Thread Amit Lavon
Sharing a package suite that I've written for my computational biology research and may be useful for others. Hope it helps! https://pkg.go.dev/github.com/fluhus/biostuff -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

[go-nuts] Array type parameters?

2022-06-05 Thread Amit Lavon
Hi, Is it possible to set a generic type parameter of "T array of any size" (not slice)? Something like: func foo[A [...]T, T constraints.Integer](a A) { m := map[A]string{} ... } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscrib

[go-nuts] Re: Array type parameters?

2022-06-06 Thread Amit Lavon
Thank you! That gives me clarity. On Monday, June 6, 2022 at 9:41:03 AM UTC+3 Jason Phillips wrote: > Not currently. See the "omissions" section of the proposal [1]: > > > No parameterization on non-type values such as constants. This arises > most obviously for arrays, where it might sometimes

[go-nuts] Performance of byte-arrays as map keys

2023-03-26 Thread Amit Lavon
Hi gophers, Some code I am writing uses byte-arrays ([X]byte) as keys in a map. I benchmarked the performance of map operations using different X's and found that 4 and 8 are about twice as fast compared to 5, 6, 7 (see below). Can someone explain this phenomenon? I'd like to learn about it so

[go-nuts] Re: Performance of byte-arrays as map keys

2023-03-29 Thread Amit Lavon
unday, March 26, 2023 at 3:05:52 AM UTC-7 Amit Lavon wrote: > >> Hi gophers, >> >> Some code I am writing uses byte-arrays ([X]byte) as keys in a map. I >> benchmarked the performance of map operations using different X's and found >> that 4 and 8 are about twi