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

2021-10-26 Thread Ben Hoyt
Ah, thanks for that info -- glad somebody is reading the docs ... :-) Seems like you're well ahead of me here. I'd be interested to hear what others have done, or what you end up with. -Ben On Wed, Oct 27, 2021 at 12:18 PM mi...@ubo.ro wrote: > That would work great but the documentation on Roun

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

2021-10-26 Thread mi...@ubo.ro
That would work great but the documentation on RoundTriper specifically forbids it[0]. Unless I get it wrong(do I?) you are not allowed to read the response within RoundTrip. The request needs to be .Clone-ed as well but that's not an issue. [0] https://pkg.go.dev/net/http#RoundTripper // Ro

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

2021-10-26 Thread mi...@ubo.ro
Thanks for your help. I'm aware I can set the headers that way but the authentication transport also needs to inspect the response headers and optionally re-submit the request based on the headers received. That's part of the "negotiation" mechanism. That's because we don;t know what authenti

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

2021-10-26 Thread ben...@gmail.com
I'm not sure what these proprietary auth schemes look like (and don't know much about oauth2 or NTLM), but for many kinds of auth you'd just set headers in the request and read them in the body. For example: request, err := http.NewRequest("GET", "https://httpbin.org/get";, nil) // handl

[go-nuts] Re: how to control the timezone of time.Now()

2021-10-26 Thread peterGo
Andrei, For database times enforce the use of these convenience functions: func DBNow() time.Time { return DBTime(time.Now()) } func DBTime(t time.Time) time.Time { return t.UTC() } Peter On Tuesday, October 26, 2021 at 2:58:16 PM UTC-4 Andrei Matei wrote: > Hello Go friends, > > I'm

Re: [go-nuts] how to control the timezone of time.Now()

2021-10-26 Thread Ian Lance Taylor
On Tue, Oct 26, 2021 at 2:07 PM Andrei Matei wrote: > > If you accept that there are reasons for setting TZ for a particular program, > then > would you also agree that there are reasons for wanting to do the same from > inside > the program? We distribute our software for others to run, so we d

Re: [go-nuts] how to control the timezone of time.Now()

2021-10-26 Thread 'Andrei Matei' via golang-nuts
On Tue, Oct 26, 2021 at 3:15 PM Ian Lance Taylor wrote: > On Tue, Oct 26, 2021 at 11:58 AM 'Andrei Matei' via golang-nuts > wrote: > > > > I'm finding it difficult to satisfactorily control the timezone used by > the time.Now() function. The Go team have taken positions in the past that > seem t

Re: [go-nuts] os/exec.Cmd Start cause child process kernel null pointer when exec

2021-10-26 Thread Ian Lance Taylor
On Tue, Oct 26, 2021 at 8:43 AM zongke cui wrote: > > I am not sure, this is bug of golang or bug of the test program ? To me it looks like a bug in the kernel. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this grou

Re: [go-nuts] how to control the timezone of time.Now()

2021-10-26 Thread Ian Lance Taylor
On Tue, Oct 26, 2021 at 11:58 AM 'Andrei Matei' via golang-nuts wrote: > > I'm finding it difficult to satisfactorily control the timezone used by the > time.Now() function. The Go team have taken positions in the past that seem > to not make this easy; I'd like to see if I can gather sympathy f

[go-nuts] how to control the timezone of time.Now()

2021-10-26 Thread 'Andrei Matei' via golang-nuts
Hello Go friends, I'm finding it difficult to satisfactorily control the timezone used by the time.Now() function. The Go team have taken positions in the past that seem to not make this easy; I'd like to see if I can gather sympathy for changes, or perhaps if there's some obvious idea that I'm mi

[go-nuts] Executing templates

2021-10-26 Thread Денис Мухортов
I can't include templates in html. A strange thing happens for me: when viewing in devtools, I see that everything is parsed first except the template, and then the template itself. Although it is included in the tag in the middle of the file. Most likely, this is due to the fact that I wrote

golang-nuts@googlegroups.com

2021-10-26 Thread Amnon
Sadly Decode does collect up the entire res.Body into memory. See https://github.com/golang/go/issues/33714 On Tuesday, 26 October 2021 at 15:25:28 UTC+1 RS wrote: > err = json.NewDecoder(res.Body).Decode(&gr) > if err != nil { > log.Println("ERROR:", err) > return > } > > Using json.newdecoder t

Re: [go-nuts] templates in html

2021-10-26 Thread Денис Мухортов
Thanks вт, 26 окт. 2021 г. в 18:32, Marcin Romaszewicz : > Have a look at this: > https://pkg.go.dev/html/template#Template.Funcs > > You need to provide a map of function names to function references to the > template engine, otherwise, it has no idea what "stoneShop" is, because all > it sees i

[go-nuts] os/exec.Cmd Start cause child process kernel null pointer when exec

2021-10-26 Thread zongke cui
following is test program: package main import ( "fmt" "os" "os/exec" "syscall" ) func main() { fmt.Printf("Args: %v\n", os.Args) for { f1, _ := os.OpenFile("/tmp/aa", os.O_RDWR|os.O_CREATE, 0755) f2, _ := os.OpenFile("/tmp/bb"

Re: [go-nuts] templates in html

2021-10-26 Thread Marcin Romaszewicz
Have a look at this: https://pkg.go.dev/html/template#Template.Funcs You need to provide a map of function names to function references to the template engine, otherwise, it has no idea what "stoneShop" is, because all it sees is an interface{} and has no context to know that it's a function. This

golang-nuts@googlegroups.com

2021-10-26 Thread RS
err = json.NewDecoder(res.Body).Decode(&gr) if err != nil { log.Println("ERROR:", err) return } Using json.newdecoder to decode the coming response body from client? Here is also the issue of " loading the entire response in memory and parsing it" is a matter? As I am not using a buffer to copy?

Re: [go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-26 Thread Brian Candler
On Monday, 25 October 2021 at 22:48:50 UTC+1 Ian Lance Taylor wrote: > unsafe.Sizeof is in unsafe mainly for > historical reasons and because there wasn't anywhere else natural to > put it. > If you *need* to know the size-in-bytes of any Go internal data structure, then you are almost certai

[go-nuts] templates in html

2021-10-26 Thread Денис Мухортов
I need to pass data from the map[string]interface{} through the template I dont know why, but I catch the error: template: stone-card.html:2: function "stoneShop" not defined. Code in go: files := []string{ dirWithHTML + "index.html", dirWithHTML + "stone-card.html",