Re: [go-nuts] How to create a generic factory?

2023-12-29 Thread 'Axel Wagner' via golang-nuts
1. Note that you can just write `NewMessage(&MessageA{}, buf)` in your example, as the type can be inferred. 2. You can use a constraint on a pointer-receiver to somewhat simplify that: https://go.dev/play/p/pEu02Bn9t3f That is not *quite* what you are asking for. It is not actually possible to rea

[go-nuts] How to create a generic factory?

2023-12-29 Thread Mazen Harake
Hi all, Assume I have a tcp server with incoming tcp packets which can be decoded in differently depending on some headers in that packet. Each message that comes in has a struct associated with it which can be created with the traditionale NewX..(buf []byte ...). After creating the object (or

Re: [go-nuts] https client 403 error

2023-12-29 Thread 'Sean Liao' via golang-nuts
see https://pkg.go.dev/net/http#Client.Jar - sean - sean On Fri, Dec 29, 2023 at 6:53 PM vlya...@gmail.com wrote: > > I use generic https client code to perform GET: > tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: > true}, } > client := &http.Client{ Transport: tr,

[go-nuts] https client 403 error

2023-12-29 Thread vlya...@gmail.com
I use generic https client code to perform GET: tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true }, } client := &http.Client{ Transport: tr, } req, err := http.NewRequest("GET", url, nil) ... resp, err := client.Do(req) for most urls it works fine but for some

[go-nuts] Re: What is the idiomatic way to create dynamic clients for Firestore in Go

2023-12-29 Thread Darrel Herbst
Use https://pkg.go.dev/cloud.google.com/go/firestore#NewClientWithDatabase to specify the databaseID. On Wednesday, December 27, 2023 at 11:51:02 PM UTC-5 Alex Breadman wrote: > I want multi-tenancy but there is no clear documentation. > > Is it supported yet in the firebase/firestore packages y