[go-nuts] Re: Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Amit Saha
On Thu, May 19, 2022 at 7:59 AM Amit Saha wrote: > > > > On Thu, May 19, 2022 at 7:02 AM Amit Saha wrote: >> >> Hi all, >> >> For a cookie, it seems like both, `Expires` and `MaxAge` must be specified? The expectation is that, only Max-Age should be sufficient. >> >> // valid >> c1 := http.Cookie

Re: [go-nuts] [generics] type constraint for structs

2022-05-18 Thread Ian Lance Taylor
On Wed, May 18, 2022 at 7:36 PM Jeremy Kassis wrote: > > Where exactly did this land? Seems like an important conversation... To date there is no way to write a constraint that requires that a type argument be a struct type. > ``` > // RPCHandler passes RPCReq and RPCRes as fn args > func RPCHa

Re: [go-nuts] [generics] type constraint for structs

2022-05-18 Thread Jeremy Kassis
Where exactly did this land? Seems like an important conversation... ``` // RPCHandler passes RPCReq and RPCRes as fn args func RPCHandler[T RPCReq, S RPCRes](fn func(T, S)) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { req := T{} if err := reqBodyRea

[go-nuts] Re: Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Amit Saha
On Thu, May 19, 2022 at 7:02 AM Amit Saha wrote: > Hi all, > > For a cookie, it seems like both, `Expires` and `MaxAge` must be > specified? The expectation is that, only Max-Age should be sufficient. > > // valid > c1 := http.Cookie{ > Expires: time.Now().Add(3600 * 24 * time.Second), >

Re: [go-nuts] Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Robert Engels
So sorry - didn’t look at the api just assumed. Apologies. > On May 18, 2022, at 4:48 PM, Amit Saha wrote: > >  > > > On Thu, May 19, 2022 at 7:43 AM Robert Engels wrote: > > > > Your first case doesn’t even work - nil is output. > > > That's a nil error - the return value from Valid() -

Re: [go-nuts] OAuth2 HttpClient customizable header

2022-05-18 Thread Robert Engels
If it is implemented correctly oauth2 is a standard that uses a Bearer token. Not sure if the other auth-scheme are usable - then it wouldn’t be oauth. Sounds like you either need an additional routing header or a different auth-scheme > On May 18, 2022, at 3:09 PM, 'Sean Liao' via golang-nuts

Re: [go-nuts] Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Amit Saha
On Thu, May 19, 2022 at 7:43 AM Robert Engels wrote: > > Your first case doesn’t even work - nil is output. That's a nil error - the return value from Valid() - indicating that the cookie is valid. > > > On May 18, 2022, at 4:11 PM, Amit Saha wrote: > >  > Hi all, > > For a cookie, it seems

Re: [go-nuts] Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Robert Engels
Your first case doesn’t even work - nil is output. > On May 18, 2022, at 4:11 PM, Amit Saha wrote: > >  > Hi all, > > For a cookie, it seems like both, `Expires` and `MaxAge` must be specified? > The expectation is that, only Max-Age should be sufficient. > > // valid > c1 := http.Cookie{ >

[go-nuts] Setting a cookie - Expires needed with MaxAge?

2022-05-18 Thread Amit Saha
Hi all, For a cookie, it seems like both, `Expires` and `MaxAge` must be specified? The expectation is that, only Max-Age should be sufficient. // valid c1 := http.Cookie{ Expires: time.Now().Add(3600 * 24 * time.Second), MaxAge: 24 * 3600, // 24 hours } // invalid c2 := http.Co

Re: [go-nuts] OAuth2 HttpClient customizable header

2022-05-18 Thread 'Sean Liao' via golang-nuts
Now that I think about it, it won't work because oauth2 will Set the Authorization header, overwriting whatever you might have originally set there. Maybe it's easier to follow standard oauth and move the original user authentication into some other header? On Wed, May 18, 2022 at 8:50 PM 'Patri

Re: [go-nuts] OAuth2 HttpClient customizable header

2022-05-18 Thread 'Patrick Kaeding' via golang-nuts
Thanks Sean! I just realized I cited the wrong package in my earlier message. I meant to refer to the golang.org/x/oauth2/clientcredentials client. I'm not sure if that matters for the discussion, but I apologize for any confusion. Is it safe to use a custom transport with this client? https

Re: [go-nuts] How to skip over or fix type-checking errors in the standard library?

2022-05-18 Thread Ian Lance Taylor
On Wed, May 18, 2022 at 4:42 AM Matt Mueller wrote: > > I'm trying to run the type-checker on some code using "go/types". I got it > working for local packages, but I'm stuck on the following when "errors" is > imported: > > ``` > could not import errors (errors/wrap.go:8:2: could not import >

Re: [go-nuts] OAuth2 HttpClient customizable header

2022-05-18 Thread 'Sean Liao' via golang-nuts
doesn't sound like a common use case, might be easier to use a transport that moves the header? - sean On Wed, May 18, 2022, 19:52 'Patrick Kaeding' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Would it be possible to allow the [header that is used]( > https://github.com/golang/oauth

[go-nuts] OAuth2 HttpClient customizable header

2022-05-18 Thread 'Patrick Kaeding' via golang-nuts
Would it be possible to allow the [header that is used](https://github.com/golang/oauth2/blob/2e8d9340160224d36fd555eaf8837240a7e239a7/token.go#L80) by the golang.org/x/oauth2 client to be overridden? I imagine the code change would be simple, but would it be accepted? My use case is that I ha

Re: [go-nuts] Go binary, that tries to run shell command in ESXI environment is failing

2022-05-18 Thread Ian Lance Taylor
On Wed, May 18, 2022 at 9:15 AM Harsh Rathore wrote: > > I will attach, the Code file and the sTrace logs. > > It basically tries to run a shell command via golang. > > When I try to run it in ESXI-670, it errors with: > > program is running > fork/exec /bin/sh: no space left on device > > Here is

[go-nuts] “Normal” vs. “error” (control flow) is a fundamental semantic distinction

2022-05-18 Thread Harri L
Hi all, I thought now was the time to go public. The automatic error propagation is possible with the help of a simple Go package, and it has been about three years now: func CopyFile(src, dst string) (err error) { defer err2.Returnf(&err, "copy %s %s", src, dst) r := try.To1(os.Open(s

[go-nuts] Go binary, that tries to run shell command in ESXI environment is failing

2022-05-18 Thread Harsh Rathore
I will attach, the Code file and the sTrace logs. It basically tries to run a shell command via golang. When I try to run it in ESXI-670, it errors with: program is running fork/exec /bin/sh: no space left on device Here is what I have tried: 1. I have tried doing this with cmd.Output().

[go-nuts] How to skip over or fix type-checking errors in the standard library?

2022-05-18 Thread Matt Mueller
Hey Gophers, I'm trying to run the type-checker on some code using "go/types". I got it working for local packages, but I'm stuck on the following when "errors" is imported: ``` could not import errors (errors/wrap.go:8:2: could not import internal/reflectlite (internal/reflectlite/value.go:10

[go-nuts] Re: Java to Go converter - 2

2022-05-18 Thread alex-coder
Henry, thank you, it is quite possible that you are right, at least I should check it out. Thank you again. среда, 18 мая 2022 г. в 07:39:49 UTC+3, Henry: > Kudos to you. Java to Go is a lot of work. Java is a more complex > language. It has more features and more possibilities for expressing