[go-nuts] HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Jochen Voss
Hello, I am using Go templates to generated the files inside an EPUB container. Since I switched to Go version 1.8 the output of my rendered templates seems to be no longer deterministic and often bit which used to be always there are now missing. Minimal working (well, broken) example:

[go-nuts] Re: HTML template behaviour changed in Go 1.8?

2017-02-26 Thread Jochen Voss
Since this is a change in behaviour since Go 1.7.5, I have now reported this as a bug: https://github.com/golang/go/issues/19294 -- 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,

Re: [go-nuts] panic: interface conversion: interface is nil, not encoding.BinaryUnmarshaler

2019-08-16 Thread Jochen Voss
Hi Axel, Thanks a lot for looking into this. Your post makes things much clearer for me. In particular, I now think that I probably should not have (Un)MarshalBinary() methods on the interface type, but have them only on the concrete type instead. For example, this works:

Re: [go-nuts] panic: interface conversion: interface is nil, not encoding.BinaryUnmarshaler

2019-08-15 Thread Jochen Voss
> > On Wed, Aug 14, 2019 at 8:46 AM Jochen Voss > wrote: > >> Hello, >> >> I'm trying to read gob-encoded data into a variable of interface type. >> In simple cases, this works for me, but when I use a custom encoding >> via MarshalBinary() and Un

Re: [go-nuts] panic: interface conversion: interface is nil, not encoding.BinaryUnmarshaler

2019-08-15 Thread Jochen Voss
Hi Axel, On Thursday, 15 August 2019 09:13:17 UTC+1, Axel Wagner wrote: > > I haven't really used gob much, so unfortunately I can't *really* help > you. But one thing to note is that you can dump the content of the buffer > and see that it doesn't actually contain the name of the type you are

[go-nuts] panic: interface conversion: interface is nil, not encoding.BinaryUnmarshaler

2019-08-14 Thread Jochen Voss
Hello, I'm trying to read gob-encoded data into a variable of interface type. In simple cases, this works for me, but when I use a custom encoding via MarshalBinary() and UnmarshalBinary() methods, my code keeps crashing, with the error message panic: interface conversion: interface is

[go-nuts] request for feedback: another websocket server implementation

2019-09-17 Thread Jochen Voss
Dear all, Because I wanted to learn about the websocket protocol, I have implemented a websocket server in Go: code: https://github.com/seehuhn/go-websocket documentation: https://godoc.org/seehuhn.de/go/websocket I would be happy to receive feedback about my code. Specific questions:

[go-nuts] Re: request for feedback: another websocket server implementation

2019-09-18 Thread Jochen Voss
2019 at 6:29:08 PM UTC-4, Jochen Voss wrote: >> >> Dear all, >> >> Because I wanted to learn about the websocket protocol, I have >> implemented a websocket server in Go: >> >> code: https://github.com/seehuhn/go-websocket >> documentation: http

[go-nuts] Re: request for feedback: another websocket server implementation

2019-09-18 Thread Jochen Voss
2019 at 6:29:08 PM UTC-4, Jochen Voss wrote: >> >> Dear all, >> >> Because I wanted to learn about the websocket protocol, I have >> implemented a websocket server in Go: >> >> code: https://github.com/seehuhn/go-websocket >> documentation: htt

[go-nuts] printing an empty slice with fmt.Printf()

2020-12-18 Thread Jochen Voss
Hello, I can print slices of bytes as hex strings, using code like the following: x := []byte{0, 1, 2, 3} fmt.Printf("%02x", x[:l]) This gives the output "00010203" as expected. But this fails for the empty slice: running x := []byte{} fmt.Printf("%02x", x[:l]) gives "00" instead of

Re: [go-nuts] printing an empty slice with fmt.Printf()

2020-12-19 Thread Jochen Voss
Dear all, Thanks for your help. The solution is indeed to use "%x" instead of "%02x". My confusion was caused by the following sentence in the docs: "For compound operands such as slices and structs, the format applies to the elements of each operand". I never spotted the relevant exception

Re: [go-nuts] ParseInt confusion

2021-02-09 Thread Jochen Voss
Oh, yes, thank you and sorry about the noise! On Tuesday, 9 February 2021 at 17:02:41 UTC ja...@kastelo.net wrote: > An int8 has a range of -128 to +127. You may be looking for > strconv.ParseUint if you want an 8 bit unsigned int? > > //jb > > On 9 Feb 2021, at 17:51,

[go-nuts] ParseInt confusion

2021-02-09 Thread Jochen Voss
Dear all, The command strconv.ParseInt("256", 8, 8) should not return an error, because octal 256 is decimal 174 which fits into 8 bits. Right? I'm asking, because actually running this command gives 'strconv.ParseInt: parsing "256": value out of range'! https://play.golang.org/p/gNKN0kKLfDd

[go-nuts] 410 Gone response from sum.golang.org for new module version?

2021-10-02 Thread Jochen Voss
Hello, I have just published a new version of my websocket library, but I cannot get it to load into the client. The error message is as follows: > go get seehuhn.de/go/websocket@v1.1.0 go: downloading seehuhn.de/go/websocket v1.1.0 go get: seehuhn.de/go/websocket@v1.1.0: verifying

[go-nuts] Re: 410 Gone response from sum.golang.org for new module version?

2021-10-02 Thread Jochen Voss
Never mind, waiting fixed it. The package showed up around 40 minutes after I published it on github. All the best, Jochen On Saturday, 2 October 2021 at 11:11:23 UTC+1 Jochen Voss wrote: > Hello, > > I have just published a new version of my websocket library, but I cannot > ge

Re: [go-nuts] Pointer to a pointer

2022-03-15 Thread Jochen Voss
Thanks for the pointer to peano.go, this is fun! It took me a while to locate the file. In case others are interested: peano.go is at https://github.com/golang/website/blob/master/_content/doc/play/peano.go and can also be found by choosing "Peano Integers" from the top-right menu in the Go

[go-nuts] evaluation of range expression in for-range loop

2022-03-18 Thread Jochen Voss
Dear all, The spec at https://go.dev/ref/spec#For_range says "The range expression x is evaluated once before beginning the loop, with one exception: if at most one iteration variable is present and len(x) is constant, the range expression is not evaluated." What does the second half of this

Re: [go-nuts] evaluation of range expression in for-range loop

2022-03-18 Thread Jochen Voss
iterate over the element > of the pointee, causing a nil-dereference panic. The clause allows this > code to work. > > On Fri, Mar 18, 2022 at 12:43 PM Jochen Voss wrote: > >> Dear all, >> >> The spec at https://go.dev/ref/spec#For_range says >> >> "

[go-nuts] type parameter names

2022-02-16 Thread Jochen Voss
Dear all, I stumbled across a difference between type names and type parameter names (in the go1.18 beta): I can re-use a type name as a variable name, but the same is not possible with type parameter names. Is this difference intentional? For illustration, the following code is valid

[go-nuts] feedback from my first experiment with generic go code

2022-02-16 Thread Jochen Voss
Dear all, Today I tried out the new generics support in Go for the first time by implementing Dijkstra's algorithm for the shortest path in a directed graph. In case it's interesting to somebody, here are my impressions, code is at https://github.com/seehuhn/go-dijkstra . The key parts of my

[go-nuts] is url->String->Parse != url a bug?

2022-03-04 Thread Jochen Voss
Hello, If I convert an url.URL to a string and then parse the result, am I meant to get back the original url? While playing with the new fuzzer I found that in practise this is not the case, but I'm not sure whether this is due to bugs, or whether this is expected. The affected URLs are of

Re: [go-nuts] is url->String->Parse != url a bug?

2022-03-04 Thread Jochen Voss
; my URL, and url2 would have the property I want. Or is there an easier way to obtain this "normalized" version? All the best, Jochen On Friday, 4 March 2022 at 13:31:50 UTC axel.wa...@googlemail.com wrote: > On Fri, Mar 4, 2022 at 2:12 PM Jochen Voss wrote: > >> If I convert an

Re: [go-nuts] Re: golang-announce is blocked in Google Groups?

2022-01-21 Thread Jochen Voss
Same here, the problem seems to have gone away. On Thursday, 20 January 2022 at 19:37:54 UTC seank...@gmail.com wrote: > For me it did show as blocked a few hours earlier but works now > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "golang-nuts"

[go-nuts] golang-announce is blocked in Google Groups?

2022-01-20 Thread Jochen Voss
Hello, It seems that golang-announce is blocked in Google Groups. When I try to access the group, I only get the following message: Banned content warning golang-announce has been identified as containing spam, malware or other malicious content. For more information about content

Re: [go-nuts] weblist in go tool pprof does not work for me

2023-09-27 Thread Jochen Voss
On 26 Sep 2023, at 6:20, Sergey Gorlov wrote: > Did you find a solution to this problem? I have the same problem with > weblist. No, I didn't. I think it's just broken. If I find time, I'll submit a bug report (unless somebody beats me to it). All the best, Jochen -- http://seehuhn.de/ --

[go-nuts] (minor) broken link in the Go 1.21 release notes.

2023-08-16 Thread Jochen Voss
Hello, Not really important, but there is a somewhat broken link in the Go 1.21 release notes. The introduction says "See “Go versions” in the “Go Toolchains” documentation for details", and this links to https://go.dev/doc/toolchain#versions The link goes to the beginning of the page,

[go-nuts] weblist in go tool pprof does not work for me

2022-06-24 Thread Jochen Voss
Hello, For a while, the "weblist" command in go tool pprof has been broken for me ("list" still works). Is this a known issue? What can I do to fix this? What I am doing: - I am using "go version go1.18.3 darwin/arm64" on a MacBook Pro (M1 Pro processor). - I am profiling one of my unit

[go-nuts] how to organise code with channels and error handling?

2022-09-23 Thread Jochen Voss
Dear all, I am writing a program which processes data in stages. To structure the code cleanly, I would like implement each stage as an individual function and use channels to pass data between stages. My questions: - How to structure the code? Is my approach described below reasonable? -

[go-nuts] maps.Keys() does not work when keys are of type language.Tag

2022-10-06 Thread Jochen Voss
Hello, Using "golang.org/x/text/language" I have a map of type map[language.Tag]int. I would like to get the keys present in my map. Why does the following command not work? import "golang.org/x/exp/maps" ... var x map[language.Tag]int ... fmt.Println(maps.Keys(x)) The

[go-nuts] returning struct vs. returning interface

2022-08-03 Thread Jochen Voss
Dear all, Why does the function NewReader [1] in compress/lzw return an io.ReadCloser instead of an *lzw.Reader? The docs say "It is guaranteed that the underlying type of the returned io.ReadCloser is a *Reader", so why not return a *Reader without wrapping? [1]

[go-nuts] Re: heap profiling does not work on M2 MacBook air?

2023-03-03 Thread Jochen Voss
023 at 2:03:22 AM UTC-5 Jochen Voss wrote: > > Hi Peter, > > Thanks a lot, giving the "-alloc_space" option makes all the difference! > With this option, it also works for me. > > I wonder whether it meant to be the way that you have to give this > option. Mayb

[go-nuts] Re: heap profiling does not work on M2 MacBook air?

2023-03-01 Thread Jochen Voss
idn't need this option to get the profile output. All the best, Jochen On Thursday, 2 March 2023 at 04:12:24 UTC peterGo wrote: > Jochen Voss, > > On linux/amd64 > > xxx.go: https://go.dev/play/p/Wq_OU49LVQZ > > $ go build xxx.go && ./xxx > > $ go tool pprof xxx mem.pro

[go-nuts] generics: can I require "comparable" together with some methods?

2023-02-17 Thread Jochen Voss
Hello, I'm trying to write a generic function like the following (simplified) one: type V interface { comparable // (1) SomeMethod(V) } func Test[val V](x val) { m := make(map[val]int) // (2) // uses a x as key in a map and calls x.SomeMethod() } When I try this, see

Re: [go-nuts] generics: can I require "comparable" together with some methods?

2023-02-17 Thread Jochen Voss
at 23:47:09 UTC Ian Lance Taylor wrote: > On Fri, Feb 17, 2023 at 3:34 PM Jochen Voss wrote: > > > > I'm trying to write a generic function like the following (simplified) > one: > > > > type V interface { > > comparable // (1) > > SomeMethod(V) > > }

Re: [go-nuts] generics: can I require "comparable" together with some methods?

2023-02-17 Thread Jochen Voss
Thanks again, reading the blog post indeed solved the problem! On Friday, 17 February 2023 at 23:47:09 UTC Ian Lance Taylor wrote: > On Fri, Feb 17, 2023 at 3:34 PM Jochen Voss wrote: > > > > I'm trying to write a generic function like the following (simplified) > one: > &

Re: [go-nuts] Another generics question

2023-02-18 Thread Jochen Voss
Thanks a lot! As an aside, the playgound is great. It made this conversation so much easier! All the best, Jochen On Saturday, 18 February 2023 at 01:31:16 UTC Ian Lance Taylor wrote: > On Fri, Feb 17, 2023 at 4:47 PM Jochen Voss wrote:, > > > > I would like to write a type c

[go-nuts] Another generics question

2023-02-17 Thread Jochen Voss
Hello, I would like to write a type constraint which matches types like the following: type v1 int func (obj v1) Add(other v1) v1 { return obj + other } type v2 string func (obj v2) Add(other v2) v2 { return obj + other } This should match anything with an Add() method which can

[go-nuts] heap profiling does not work on M2 MacBook air?

2023-03-01 Thread Jochen Voss
Dear all, I'm trying to profile memory use of a program, following the instructions at https://go.dev/blog/pprof , but I can't get memory profiling to work. Am I doing things wrong, or is this broken? Simplified code is at https://go.dev/play/p/Wq_OU49LVQZ . (The code doesn't run on the

[go-nuts] Re: heap profiling does not work on M2 MacBook air?

2023-03-01 Thread Jochen Voss
The problem also occurs on AMD64 Linux, so it's not architecture specific. Hints would be most welcome! On Wednesday, 1 March 2023 at 13:55:30 UTC Jochen Voss wrote: > Dear all, > > I'm trying to profile memory use of a program, following the instructions > at https://go.de

Re: [go-nuts] Re: heap profiling does not work on M2 MacBook air?

2023-03-01 Thread Jochen Voss
gt; 0 0% 100% 513.31kB 100% runtime.main > 0 0% 100% 513.31kB 100% > seehuhn.de/go/pdf/font/tounicode.init > > - sean > > > On Wed, Mar 1, 2023 at 11:25 PM Jochen Voss wrote: > >> The problem also occurs on AMD64 Linux, so it's

[go-nuts] finding the call graph of a method

2023-04-18 Thread Jochen Voss
Dear all, I'm trying to find the callgraph of a method, using the following code: package main import ( "log" "golang.org/x/tools/go/callgraph" "golang.org/x/tools/go/packages" "golang.org/x/tools/go/ssa/ssautil" ) func main() { cfg := {Mode: packages.LoadSyntax} initial, err :=

[go-nuts] Re: finding the call graph of a method

2023-04-19 Thread Jochen Voss
Ah, found it! If I write types.NewPointer(reader.Type()) instead of just reader.Type(), things work better. On Tuesday, 18 April 2023 at 20:34:30 UTC+1 Jochen Voss wrote: > Dear all, > > I'm trying to find the callgraph of a method, using the following code: > > package

[go-nuts] getting the size of an io.ReaderAt?

2023-03-31 Thread Jochen Voss
Dear all, I am trying to get the size of an io.ReaderAt, i.e. the offset after which no more data can be read. I have some working (?) code (https://go.dev/play/p/wTouYbaJ7RG , also reproduced below), but I am not sure whether what I do is correct and the best way to do this. Some

Re: [go-nuts] getting the size of an io.ReaderAt?

2023-04-01 Thread Jochen Voss
en you do not need to do that. > > > On Fri, Mar 31, 2023 at 4:30 PM Jochen Voss wrote: > >> Dear all, >> >> I am trying to get the size of an io.ReaderAt, i.e. the offset after >> which no more data can be read. I have some working (?) code ( >> https://

[go-nuts] regexp question

2023-02-10 Thread Jochen Voss
Dear all, What happens if a group in a regular expression matches repeatedly, via the * operator? Experimentally I found that FindStringSubmatch then returns the text of the last match. Is this guaranteed somewhere (I didn't find anything about this on https://pkg.go.dev/regexp )? Also, is

[go-nuts] Re: regexp question

2023-02-10 Thread Jochen Voss
bavy wrote: > FindAllStringSubmatch() ? > https://pkg.go.dev/regexp#Regexp.FindAllStringSubmatch > > On Friday, 10 February 2023 at 12:52:34 UTC Jochen Voss wrote: > >> Dear all, >> >> What happens if a group in a regular expression matches repeatedly, via

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
y, July 18, 2023 at 10:45:18 AM UTC-4 Jan Mercl wrote: > >> On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wrote: >> >> > Is there a better way? >> >> I have never been here and please don't do this: >> https://go.dev/play/p/x4QYJubXMnQ >> > -

[go-nuts] Re: testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
>>> >>> I don't think you need to check both maps when choosing a key. Once >>> you've found a candidate key in one map, you can test the other map and if >>> it *does* exist then the two maps aren't equal. You've then saved the >>> insertion and deletion step. I would

[go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Dear all, To implement the "eq" operator in a simple PostScript interpreter, I need to determine whether two maps are the same object. This can be done by adding a new element to one map, and checking whether the new entry also appears in the second map, but as you can imagine, the resulting

[go-nuts] failed fuzz tests not reproducible when re-run

2023-08-02 Thread Jochen Voss
Dear all, Recently I find quite often that after "go test -fuzz" reported an error, the command shown to re-run the test does not reproduce the failure. For example, just now I got the following: voss@dumpling [..nt/tounicode2] go test -fuzz FuzzToUnicode fuzz: elapsed: 0s, gathering baseline

[go-nuts] Re: heap profiling does not work on M2 MacBook air?

2024-01-27 Thread Jochen Voss
I've now filed https://github.com/golang/go/issues/65328 to report this. On Friday 3 March 2023 at 09:47:26 UTC Jochen Voss wrote: > Hi Peter, > > Thanks again for looking into this, and for your help! > > You mention that the blog post was long ago. I wonder whether the c

[go-nuts] generics question

2024-04-22 Thread Jochen Voss
Using generics, can I somehow write a constraint which says that *T (instead of T) implements a certain interface? The following code illustrated what I'm trying to do: type A int func (a *A) Set(x int) { *a = A(x) } type B string func (b *B) Set(x int) { *b = B(strconv.Itoa(x)) } type C1

Re: [go-nuts] generics question

2024-04-23 Thread Jochen Voss
c.Val { var ptr P = &(c.Val[i]) ptr.Set(v) } } var c = C[A, *A]{Val: []A{1, 2, 3}} On Tuesday 23 April 2024 at 03:36:25 UTC+1 Nagaev Boris wrote: > On Mon, Apr 22, 2024 at 9:54 PM Ian Lance Taylor wrote: > > > > On Mon, Apr 22, 2024 at 2:25 PM Jochen Voss wrote: > > &g

[go-nuts] tls.VerifyClientCertIfGiven

2024-05-15 Thread Jochen Voss
Hello, In a server I use tls.Config.ClientAuth=tls.VerifyClientCertIfGiven. If then a client manages to connect and I can see a certificate in http.Request.TLS.PeerCertificates, does this just mean that the client has the certificate, or does this also prove that the client has the associated

[go-nuts] replacement for filepath.HasPrefix?

2024-05-16 Thread Jochen Voss
Dear all, filepath.HasPrefix is deprecated, because it doesn't alway work. What would be a replacement for this function, which at least respects path boundaries, and maybe also ignores case when needed? All the best, Jochen -- You received this message because you are subscribed to the

[go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Jochen Voss
Hello, In the Go standard library, in the file log/slog/handler.go, I found the following code: func (h *commonHandler) clone() *commonHandler { // We can't use assignment because we can't copy the mutex. return { json: h.json, opts: h.opts, preformattedAttrs: