Re: [go-nuts] Example tests: access to module testdata files

2025-01-21 Thread Rory Campbell-Lange
gt; the source code. > Consider embedding any files you need with "embed" and accessing them > through io/fs.FS rather than through os calls. > > - sean > > On Fri, Jan 10, 2025 at 8:51 AM Rory Campbell-Lange > wrote: > > > > Hi. I have written a small pac

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-14 Thread Rory Campbell-Lange
for me > :) > > The source is here > https://github.com/rogpeppe/misc/blob/f64633da4fd4/cmd/base64/base64.go > > On Tue, 14 Jan 2025 at 14:53, Rory Campbell-Lange > wrote: > > > Thanks for finding that foolish error, Brian. > > > > To wrap the thread up, th

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-14 Thread Rory Campbell-Lange
j o u r , j o y e u x > >> 010 l i o n \n > >> 0000015 > >> > >> % echo -n "IkJvbmpvdXIsIGpveWV1eCBsaW9uIg==" | base64 -D | hexdump -c > >> 000 " B o n j o u r , j o y

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-13 Thread Rory Campbell-Lange
of the count of characters > read before eof to determine how many padding characters to synthetically add > - if the original data is padding this will be 0 (if it was padded correctly). > > > On Jan 13, 2025, at 4:42 PM, Rory Campbell-Lange > > wrote: > > > > AS I

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-13 Thread Rory Campbell-Lange
IkJvbmpvdXIsIGpveWV1eCBsaW9uIg== ok: true decoded: "Bonjour, joyeux lion" -- Any thoughts on that would be gratefully received. Rory On 13/01/25, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > Thanks very muc

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-13 Thread Rory Campbell-Lange
e underlying io.Reader and > >> a buffer to store the pushed-back bytes. > >> > > NewPushbackReader: This function creates a new PushbackReader from an > >> existing io.Reader. > >> > > Read method: This method reads bytes from either the buffer

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-12 Thread Rory Campbell-Lange
experimental. > > > >> On Jan 12, 2025, at 2:53 PM, Robert Engels wrote: > >> > >> You can see the two pass reader here > >> https://stackoverflow.com/questions/20666594/how-can-i-push-bytes-into-a-reader-in-go > >> > >> But yea,

Re: [go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-12 Thread Rory Campbell-Lange
on. > > > On Jan 12, 2025, at 12:52 PM, Rory Campbell-Lange > > wrote: ... > > I'm attempting to rationalise the process [of avoiding reading email parts > > into byte slices] by simply wrapping the provided io.Reader with the > > necessary decoders to r

[go-nuts] Efficiently switch io.Reader to another decoder on error

2025-01-12 Thread Rory Campbell-Lange
I'm looking to develop an alternative to an existing piece of code that reads email parts into byte slices and then returns these after decoding. As library users may not wish to use these email parts and because there a multiple byte slice copies being used, I'm attempting to rationalise the p

Re: [go-nuts] Golang ORM Performances

2025-01-10 Thread Rory Campbell-Lange
On 10/01/25, 'Brian Candler' via golang-nuts (golang-nuts@googlegroups.com) wrote: > On Thursday, 9 January 2025 at 19:49:23 UTC Roland Müller wrote: > > > Reason for that is that doing all DB access methods in the application > > language (Go or Java) tends to a codebase where you have SQL code

[go-nuts] Example tests: access to module testdata files

2025-01-10 Thread Rory Campbell-Lange
Hi. I have written a small package with an example which runs fine locally, but doesn't work through the web interface of either my local godoc or pkg.go.dev. https://pkg.go.dev/github.com/rorycl/mailboxoperator@v0.0.4#example-package The test attempts to access files in the testdata directories

[go-nuts] draft 1.24 release notes: broken link

2024-12-10 Thread Rory Campbell-Lange
Hi The draft go 1.24 release notes at https://tip.golang.org/doc/go1.24 have a broken link relating to generic type aliases. https://tip.golang.org/issue/46477 has a broken POST (?!) which results in a "open issue/46477: file does not exist". Perhaps that link should be https://github.com/gola

Re: [go-nuts] Can't range over iter.Seq in text/template (go 1.22/dev)

2024-07-07 Thread Rory Campbell-Lange
On 06/07/24, Ian Lance Taylor (i...@golang.org) wrote: > On Sat, Jul 6, 2024 at 2:21 PM Rory Campbell-Lange > wrote: > > > > I don't seem to be able to range over an iter.Seq in a template. ... > > ...is an iter.Seq or iter.Seq2 not intended to be added there? >

[go-nuts] Can't range over iter.Seq in text/template (go 1.22/dev)

2024-07-06 Thread Rory Campbell-Lange
I don't seem to be able to range over an iter.Seq in a template. error: executing "test" at <.>: range can't iterate over 0x5103c0 resulter := func(yield func(int) bool) { for _, v := range []int{1, 2, 3} { if !yield(v) {

Re: [go-nuts] multiple rangefunc iterators: restart?

2024-05-31 Thread Rory Campbell-Lange
On 31/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > On 23/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > > I've been playing with with rangefunc experiment... > > ...reference to python nested yield example... > > > for p in people

Re: [go-nuts] multiple rangefunc iterators: restart?

2024-05-31 Thread Rory Campbell-Lange
On 23/05/24, Rory Campbell-Lange (r...@campbell-lange.net) wrote: > I've been playing with with rangefunc experiment... ...reference to python nested yield example... > for p in people: > for c in p.cars: > for t in c.tickets: > pri

[go-nuts] multiple rangefunc iterators: restart?

2024-05-23 Thread Rory Campbell-Lange
I've been playing with with rangefunc experiment, with help from https://go.dev/wiki/RangefuncExperiment and the possible idioms that might come out of it (https://blog.perfects.engineering/go_range_over_funcs is a good read). One somewhat eccentric use of nested iterators I built in the past i

Re: [go-nuts] Cannot set http 413 status from http.MaxBytesReader

2023-08-29 Thread Rory Campbell-Lange
On 29/08/23, Nagaev Boris (bnag...@gmail.com) wrote: > On Tue, Aug 29, 2023 at 5:44 PM Rory Campbell-Lange > wrote: > > > > I've made an http middleware that uses http.MaxBytesReader to limit the > > accepted size of requests. ... > > It seems sensible to se

[go-nuts] Cannot set http 413 status from http.MaxBytesReader

2023-08-29 Thread Rory Campbell-Lange
I've made an http middleware that uses http.MaxBytesReader to limit the accepted size of requests. The middleware is as follows: func bodyLimitMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.Body = http

Re: [go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread Rory Campbell-Lange
On 06/03/23, Bruno Albuquerque (b...@gmail.com) wrote: > You can easily get it to work, but not in a useful way I guess. > > https://go.dev/play/p/mq0O8OhJ1-a > > You could have a different template for each type you use I guess. Thanks for that solution. I guess I could do t.Funcs(template

[go-nuts] cannot register generic function with template.Funcs

2023-03-06 Thread Rory Campbell-Lange
Hi. I have a generic function func slicerG[A any](s []A, i int) []A { fmt.Println(len(s), i) if i > len(s) { return s } return s[0:i] } When I try to register this in a template's FuncMap, it fails with "cannot use generic function slicerG with

[go-nuts] Pass SQL null values to Parquet

2023-01-22 Thread Rory Campbell-Lange
I'm writing a PostgreSQL dump file to parquet converter as a hobby project. PostgreSQL dump files are simply plain-text files containing, as the man page puts it "the SQL commands required to reconstruct the database to the state it was in at the time it was saved." Null SQL values are represent

Re: [go-nuts] understanding interface conversions

2022-09-23 Thread Rory Campbell-Lange
On 23/09/22, Ian Davis (m...@iandavis.com) wrote: > On Thu, 22 Sep 2022, at 11:27 PM, Rory Campbell-Lange wrote: > > I just wanted to respond to this part: > > > I suppose my question is (and forgive me if this is a terrifically naive), > > how can one negotiate the go la

Re: [go-nuts] understanding interface conversions

2022-09-23 Thread Rory Campbell-Lange
On 22/09/22, burak serdar (bser...@computer.org) wrote: > On Thu, Sep 22, 2022 at 4:27 PM Rory Campbell-Lange > wrote: > > > ...I'm interested to learn how people negotiate interface > > interchangeability in their programmes as my query above showed a basic > &

[go-nuts] understanding interface conversions

2022-09-22 Thread Rory Campbell-Lange
This email follows my email yesterday "cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)". Thanks very much to those who replied and provided solutions. Following that, I'm interested to learn how people negotiate interface interchangeability in their programmes as my query above sh

Re: [go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-22 Thread Rory Campbell-Lange
On 22/09/22, 'Dan Kortschak' via golang-nuts (golang-nuts@googlegroups.com) wrote: > On Thu, 2022-09-22 at 00:58 +0100, Rory Campbell-Lange wrote: > > interface conversion: *zip.checksumReader is not io.ReadSeeker: > > missing method Seek > > Would it be accep

[go-nuts] cannot convert fs.FS zip file to io.ReadSeeker (missing Seek)

2022-09-21 Thread Rory Campbell-Lange
I have a program that needs to work equally for a directory of files or for the contents of a zip file, so I'm using an fs.FS to abstract the two. Some of the files need to be provided to a PDF importer that accepts an io.ReadSeeker (#1). Generally this is working fine except when trying to co

Re: [go-nuts] io.WriteString to a file panics

2022-04-12 Thread Rory Campbell-Lange
On 12/04/22, 'Sean Liao' via golang-nuts (golang-nuts@googlegroups.com) wrote: > > output, err := os.Create(o) > The short variable declaration you used to create `err` also shadows > `output`. Thanks very much for pointing out this shadowing problem. > > var err error > output, err = os.Create(

[go-nuts] io.WriteString to a file panics

2022-04-12 Thread Rory Campbell-Lange
I have a command line programme that can output to either stdout or a named file. Output to stdout, as commented out in the small example below, works fine, but not to a named file. Attempting to write to a named file panics on go 1.17 on Linux with: panic: runtime error: invalid memory add

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Rory Campbell-Lange
On 27/06/21, Brian Candler (b.cand...@pobox.com) wrote: > On Sunday, 27 June 2021 at 10:32:22 UTC+1 ro...@campbell-lange.net wrote: > > > By the way, as a golang newbie, it isn't clear to me when it is advisable > > to use a channel for locking as opposed to a mutex. Do people tend to use > > the

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Rory Campbell-Lange
On 27/06/21, Brian Candler (b.cand...@pobox.com) wrote: > > Shouldn't that result in a panic, even without -race? > > It's not *guaranteed* to panic when you make concurrent accesses to the > same map (hence the point of the race checker). And having two structs > refer to the same map is no di

Re: [go-nuts] Data race problem with mutex protected maps

2021-06-27 Thread Rory Campbell-Lange
On 26/06/21, Ian Lance Taylor (i...@golang.org) wrote: > On Sat, Jun 26, 2021 at 3:27 PM Rory Campbell-Lange wrote: > > > > I'm trying to work out why I have a data race problem (on go 1.15 and 1.16). > > > > *SearchResults.Set is called from several

[go-nuts] Data race problem with mutex protected maps

2021-06-26 Thread Rory Campbell-Lange
I'm trying to work out why I have a data race problem (on go 1.15 and 1.16). *SearchResults.Set is called from several goroutines. I am trying to avoid concurrent access to its two maps using a mutex, but this isn't working. 108 type SearchResults struct { 109 Boxes map[string][]Box 110 s

[go-nuts] recommended approach for loading private keys requiring passwords

2020-04-26 Thread Rory Campbell-Lange
I've been working on a small service for inserting ssh certificates into ssh forwarded agents. See https://github.com/rorycl/sshagentca The idea is that if you have an ssh forwarded agent with a certificate signed through the service, you can connect to any ssh server which has the TrustedUser