[go-nuts] https://go-talks.appspot.com still working?
I tried an older URL of mine and I do get with this URL: https://go-talks.appspot.com/github.com/jum/htempl/slides/htempl.slide This error: Error accessing api.github.com. 403: (https://api.github.com/repos/jum/htempl) Is this my error or is go-talks not working any more? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/385c9128-3424-4332-abc0-b9eac389f667n%40googlegroups.com.
Re: [go-nuts] Re: https://go-talks.appspot.com still working?
Someone must have fixed something, as it was not working when I posted. On Saturday, May 13, 2023 at 4:54:29 PM UTC+2 peterGo wrote: > https://api.github.com/repos/jum/htempl > > takes me to > > { > "id": 205554689, > "node_id": "MDEwOlJlcG9zaXRvcnkyMDU1NTQ2ODk=", > "name": "htempl", > "full_name": "jum/htempl", > "private": false, > "owner": { > "login": "jum", > "id": 33510, > "node_id": "MDQ6VXNlcjMzNTEw", > "avatar_url": "https://avatars.githubusercontent.com/u/33510?v=4";, > "gravatar_id": "", > "url": "https://api.github.com/users/jum";, > "html_url": "https://github.com/jum";, > "followers_url": "https://api.github.com/users/jum/followers";, > "following_url": " > https://api.github.com/users/jum/following{/other_user}";, > "gists_url": "https://api.github.com/users/jum/gists{/gist_id}";, > "starred_url": " > https://api.github.com/users/jum/starred{/owner}{/repo}";, > "subscriptions_url": "https://api.github.com/users/jum/subscriptions";, > "organizations_url": "https://api.github.com/users/jum/orgs";, > "repos_url": "https://api.github.com/users/jum/repos";, > "events_url": "https://api.github.com/users/jum/events{/privacy}";, > "received_events_url": " > https://api.github.com/users/jum/received_events";, > "type": "User", > "site_admin": false > }, > > > peter > > > On Sat, May 13, 2023 at 10:46 AM peterGo wrote: > >> It is your error. >> >> https://go-talks.appspot.com/github.com/jum/htempl/slides/htempl.slide >> >> takes me to >> >> https://go-talks.appspot.com/github.com/jum/htempl/slides/htempl.slide#1 >> >> the slide deck. >> >> peter >> On Saturday, May 13, 2023 at 10:17:18 AM UTC-4 Jens-Uwe Mager wrote: >> >>> I tried an older URL of mine and I do get with this URL: >>> >>> https://go-talks.appspot.com/github.com/jum/htempl/slides/htempl.slide >>> >>> This error: >>> >>> Error accessing api.github.com. 403: ( >>> https://api.github.com/repos/jum/htempl) >>> >>> Is this my error or is go-talks not working any more? >>> >>> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "golang-nuts" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/golang-nuts/leJ8rtmgtN8/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> golang-nuts...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/47f7a84f-96f7-4ac0-8ca4-6fd182a2bb92n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/47f7a84f-96f7-4ac0-8ca4-6fd182a2bb92n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4a7c77bc-d65b-4482-90dd-5ccf2cca854dn%40googlegroups.com.
[go-nuts] Types like http.Request and slog.LogValuer
I am trying to convert some older code to slog and I am running into the issue that if some data structure contains http.Request I get the message: {"time":"2023-07-27T15:49:04.744214+02:00","level":"DEBUG","msg":"req","r":"!ERROR:json: unsupported type: func() (io.ReadCloser, error)"} So I believed it would be a good idea to add a LogValue() function to http.Request that used httputil.DumpRequest(), but that does not work as I cannot add methods from my code. Any good idea to approach that? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8ffe7eb7-e594-427d-a053-f2dc9227fb49n%40googlegroups.com.
[go-nuts] Re: Types like http.Request and slog.LogValuer
There is a slight problem here that the requestWrapper would have to be implemented very deep through many layers of library. For example there might be a data structure passed down a chain of handlers with a custom argument structure, which contains a http.Request per some old design decisions. Switching to slog probably makes me revisit this design, as I cannot easily get the http.Request out of that structure easily. And this custom structure is logged all over the place. Oh well. On Saturday, July 29, 2023 at 12:18:53 PM UTC+2 Jonathan Amsterdam wrote: > I would write a type that wraps the request and implements LogValuer. Then > you would log the request as > > logger.Debug("req", "r", requestWrapper{r}) > > On Thursday, July 27, 2023 at 10:01:27 AM UTC-4 Jens-Uwe Mager wrote: > >> I am trying to convert some older code to slog and I am running into the >> issue that if some data structure contains http.Request I get the message: >> >> {"time":"2023-07-27T15:49:04.744214+02:00","level":"DEBUG","msg":"req","r":"!ERROR:json: >> >> unsupported type: func() (io.ReadCloser, error)"} >> >> So I believed it would be a good idea to add a LogValue() function to >> http.Request that used httputil.DumpRequest(), but that does not work as I >> cannot add methods from my code. Any good idea to approach that? >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a42d3bce-86d0-43dd-8895-4bd3a524cddfn%40googlegroups.com.
[go-nuts] html/template escaping problem
I am having a problem to properly escape javascript urls in my templates. I do have the situation where I build a template that is having javascript urls that are from variables in the go program (read from yaml files). The go program generates static html, but the html is supposed to use moustache.js to expand some further variables at render time. I am just not able to preserve my javascript from the html/template escaping. Any ideas what I am doing wrong? The output is: {{test}} But I would like it to be: {{test}} package main import ( "html/template" "os" ) var t = template.Must(template.New("test").Funcs(template.FuncMap{ "safeattr": func(value string) template.HTMLAttr { return template.HTMLAttr(value) }, "safehtml": func(value string) template.HTML { return template.HTML(value) }, "safejs": func(value string) template.JS { return template.JS(value) }, "safecss": func(value string) template.CSS { return template.CSS(value) }, "safeurl": func(value string) template.URL { return template.URL(value) }, }).Parse(` {{safehtml .content}} `)) func main() { data := map[string]string{ "href":"javascript:doSlide('{{area}}');", "content": "{{test}}", } err := t.Execute(os.Stdout, data) if err != nil { panic(err) } } https://play.golang.org/p/F2EiuECCZWo -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0c93e49c-1e8b-4617-baef-0848b57fde93%40googlegroups.com.
Re: [go-nuts] html/template escaping problem
This gives me the output: {{test}} So this does not work at all. On Monday, September 9, 2019 at 4:20:06 PM UTC+2, Kurtis Rader wrote: > > You have > > href="{{safeurl .href}}", > > Shouldn't that be "safejs"? Using "safehref" is causing the string to be > hex encoded as a URL. Which means most special chars will be converted to > hex representation. > > On Mon, Sep 9, 2019 at 4:53 AM Jens-Uwe Mager > wrote: > >> I am having a problem to properly escape javascript urls in my templates. >> I do have the situation where I build a template that is having javascript >> urls that are from variables in the go program (read from yaml files). The >> go program generates static html, but the html is supposed to use >> moustache.js to expand some further variables at render time. I am just not >> able to preserve my javascript from the html/template escaping. Any ideas >> what I am doing wrong? >> >> The output is: >> >> {{test}} >> >> >> But I would like it to be: >> >> {{test}} >> >> >> package main >> >> import ( >> "html/template" >> "os" >> ) >> >> var t = template.Must(template.New("test").Funcs(template.FuncMap{ >> "safeattr": func(value string) template.HTMLAttr { >> return template.HTMLAttr(value) >> }, >> "safehtml": func(value string) template.HTML { >> return template.HTML(value) >> }, >> "safejs": func(value string) template.JS { >> return template.JS(value) >> }, >> "safecss": func(value string) template.CSS { >> return template.CSS(value) >> }, >> "safeurl": func(value string) template.URL { >> return template.URL(value) >> }, >> }).Parse(` >> {{safehtml .content}} >> `)) >> >> func main() { >> data := map[string]string{ >> "href":"javascript:doSlide('{{area}}');", >> "content": "{{test}}", >> } >> err := t.Execute(os.Stdout, data) >> if err != nil { >> panic(err) >> } >> } >> >> >> >> https://play.golang.org/p/F2EiuECCZWo >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golan...@googlegroups.com . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/0c93e49c-1e8b-4617-baef-0848b57fde93%40googlegroups.com >> >> <https://groups.google.com/d/msgid/golang-nuts/0c93e49c-1e8b-4617-baef-0848b57fde93%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/556ed9b5-8d41-4826-bdfc-fab4eb503d80%40googlegroups.com.
[go-nuts] Re: html/template escaping problem
I finally got a workaround going, and that is to not have any moustache template in the javascript at all. By putting the {{area}} template in an data-xxx attribute of the element I can access this from the javascript. On Monday, September 9, 2019 at 1:53:34 PM UTC+2, Jens-Uwe Mager wrote: > > I am having a problem to properly escape javascript urls in my templates. > I do have the situation where I build a template that is having javascript > urls that are from variables in the go program (read from yaml files). The > go program generates static html, but the html is supposed to use > moustache.js to expand some further variables at render time. I am just not > able to preserve my javascript from the html/template escaping. Any ideas > what I am doing wrong? > > The output is: > > {{test}} > > > But I would like it to be: > > {{test}} > > > package main > > import ( > "html/template" > "os" > ) > > var t = template.Must(template.New("test").Funcs(template.FuncMap{ > "safeattr": func(value string) template.HTMLAttr { > return template.HTMLAttr(value) > }, > "safehtml": func(value string) template.HTML { > return template.HTML(value) > }, > "safejs": func(value string) template.JS { > return template.JS(value) > }, > "safecss": func(value string) template.CSS { > return template.CSS(value) > }, > "safeurl": func(value string) template.URL { > return template.URL(value) > }, > }).Parse(` > {{safehtml .content}} > `)) > > func main() { > data := map[string]string{ > "href":"javascript:doSlide('{{area}}');", > "content": "{{test}}", > } > err := t.Execute(os.Stdout, data) > if err != nil { > panic(err) > } > } > > > > https://play.golang.org/p/F2EiuECCZWo > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/865e2df0-db52-4dd8-8c84-43c2cc56c599%40googlegroups.com.
[go-nuts] http: unexpected EOF reading trailer not a temporary error?
I am checking net.error for the Temporary() condition, and in my very bad network I do see really a lot of errors. While doing a GET request I see that http: unexpected EOF reading trailer is not a temporary error, so my retry logic does not kick in. Is this a special case or just an oversight? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] http: unexpected EOF reading trailer not a temporary error?
Looking further into this, I see this as a typical transient error in a bad network on downloading files. It may be different elsewhere, but I have to retry on that error as it appears. And I cannot change the network somewhere in the Guatemala outback. On Monday, April 16, 2018 at 4:59:28 PM UTC-6, Ian Lance Taylor wrote: > > On Mon, Apr 16, 2018 at 3:09 PM, Jens-Uwe Mager > wrote: > > > > I am checking net.error for the Temporary() condition, and in my very > bad > > network I do see really a lot of errors. While doing a GET request I see > > that > > > > http: unexpected EOF reading trailer > > > > is not a temporary error, so my retry logic does not kick in. Is this a > > special case or just an oversight? > > EOF means that the TCP connection has closed, so this error is not > temporary. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Godoc command in the future http server only?
I am using the godoc command to get the complete documentaion of a package vs. the short form the go doc normally generates. For example the following alias: alias gdf="go list ./...|fzf --preview 'go doc {}' --bind 'enter:execute(godoc {}|less)'" works for me as a nice terminal go documentation browser for the current go source tree I issue the command from. But this alias relies on godoc delivering the complete package documentation and go doc to do the usual summary. Any way to keep that feature when godoc is going http only in future releases? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] godoc.org (and pkg.go.dev) only showing one global function?
I am having problems that some of the docs I am looking at show only one single line of exported global functions. Example here https://godoc.org/golang.org/x/text/language#pkg-index Running this command: go doc golang.org/x/text/language I get much more exported global functions: ... func CompactIndex(t Tag) (index int, exact bool) func Compose(part ...interface{}) (t Tag, err error) func EncodeM49(r int) (Region, error) func Parse(s string) (t Tag, err error) func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) func ParseBase(s string) (Base, error) func ParseExtension(s string) (e Extension, err error) func ParseRegion(s string) (Region, error) func ParseScript(s string) (Script, error) func ParseVariant(s string) (Variant, error) ... any preference I can set at godoc.org (or pkg.go.dev) to see all available global functions? Or is this a bug? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d0722133-7a01-4418-b998-70e68921d1d4o%40googlegroups.com.
[go-nuts] Re: godoc.org (and pkg.go.dev) only showing one global function?
The go doc command lists these under global functions, whereas godoc.org and pkg.go.dev was listing them under the base type they return for example ParseAcceptLang was listed under Tag. The difference between go doc and the web based documentation confused me. Shouldn't the output of both ways be comparable? On Monday, June 29, 2020 at 2:11:31 PM UTC+2, Jens-Uwe Mager wrote: > > I am having problems that some of the docs I am looking at show only one > single line of exported global functions. Example here > > https://godoc.org/golang.org/x/text/language#pkg-index > > Running this command: > > go doc golang.org/x/text/language > > I get much more exported global functions: > > ... > func CompactIndex(t Tag) (index int, exact bool) > func Compose(part ...interface{}) (t Tag, err error) > func EncodeM49(r int) (Region, error) > func Parse(s string) (t Tag, err error) > func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) > func ParseBase(s string) (Base, error) > func ParseExtension(s string) (e Extension, err error) > func ParseRegion(s string) (Region, error) > func ParseScript(s string) (Script, error) > func ParseVariant(s string) (Variant, error) > ... > > any preference I can set at godoc.org (or pkg.go.dev) to see all > available global functions? Or is this a bug? > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b19c7235-6092-4e61-87e1-4ffa0ffa649ao%40googlegroups.com.