[go-nuts] oauth2/jws creates "invalid" signatures

2022-05-01 Thread mi...@ubo.ro
Does anyone know why the jws signatures created by the golang.org/x/oauth2/jws are displayed as "invalid signature" on jwt.io ? As far as I'm concerned it seems compliant with the JWS creation specs[0] but it looks like jwt.io is expecting a public key or "jwk string" as well ? Below is an ex

[go-nuts] Is it possible to define a generic/inherited method?

2022-04-14 Thread mi...@ubo.ro
I have a function that encodes Go data structure in a certain way. Below is a an example // Data structure type DataX struct{ X string `query:"x"` } func MarshalJSON(v interface)([]byte, error){ s := query.Encode(v) return s.Bytes(), nil } Currently in order to force the json encoder u

[go-nuts] go/wasm how to test browser APIs

2022-04-08 Thread mi...@ubo.ro
I'm trying to unitest a browser wasm/js application but it seems that the browser objects are missing. I assume that the testing package is using a "serverside" node API so I wonder how can I make go test use a real browser to run the tests. The test below fails func TestTransform(t *testing.T)

[go-nuts] Re: How to negotiate authentication over HTTP ? (the Go way)

2021-10-26 Thread mi...@ubo.ro
Timeout: 5 * time.Second,Transport: &AuthTransport{AuthHeader: "abcd1234"},}* *Did that not work for you?* *-Ben* On Wednesday, October 27, 2021 at 1:52:18 AM UTC+3 mi...@ubo.ro wrote: > Thanks for your help. I'm aware I can set the headers that way but the >

[go-nuts] Re: How to negotiate authentication over HTTP ? (the Go way)

2021-10-26 Thread mi...@ubo.ro
// handle err > // handle response > > Runnable code example here: > https://play.golang.org/p/cocv1avzNCo > > And of course you can roll your own function to create a new request with > auth headers already applied. Would this kind of thing work for you? > > -Ben &

[go-nuts] How to negotiate authentication over HTTP ? (the Go way)

2021-10-25 Thread mi...@ubo.ro
I find myself in need to handle various authentication schemes such "proprietary" oauth2 schemes and NTLM. The easy and clean way to do it (API wise) would be using a http.RoundTripper but looks like it forbids you from even reading the response headers. In the end I just made a ``func DoHTTPR

Re: [go-nuts] Can generics help me make my library safer?

2021-10-08 Thread mi...@ubo.ro
;> cases to ensure the code is correct. >> >> Far simpler and more robust in my opinion. >> >> On Oct 6, 2021, at 6:35 AM, roger peppe wrote: >> >>  >> >> On Wed, 6 Oct 2021 at 09:21, mi...@ubo.ro wrote: >> >>> Hi Ian , >&

Re: [go-nuts] Can generics help me make my library safer?

2021-10-06 Thread mi...@ubo.ro
evity return []reflect.Type{t.Field(0).Type}, nil } func fieldsFromResource(v reflect.Value) []interface{} { // skip type fields looping for brevity return []interface{}{ v.Field(0).Addr().Interface(), v.Field(1).Addr().Interface(), v.Field(2).Addr().Interface(), } } On Wednesday, October 6, 202

[go-nuts] Can generics help me make my library safer?

2021-10-03 Thread mi...@ubo.ro
I have developed a library that depends very much on reflect package. It caches a specific type and return a function that encodes(does something with) with that kind /type of data. Think of defining database schema using types and generating functions to validate/update/insert data. I reduced

[go-nuts] promoted methods confusion

2021-02-22 Thread mi...@ubo.ro
Is there any proposal in Go 2.0 to remove the promotion of methods on embedded struct fields or do you think it's a good idea ? For example in the code below if someone marshals `Pack`, only `Animal` is actually marshalled. Cat field is skipped. If he wants to marshal Cat as well the developer