Dear all,
I am looking at the source code for the new "unique" package (just out of
curiosity).
One thing I did not understand: why is `zero` defined to be an `uintptr`?
https://cs.opensource.google/go/go/+/master:src/unique/handle.go;l=16
My understanding is the `zero` variable just provides a
Hi Brian,
One instance where (1) would be useful is, when trying to implement a
PostScript interpreter. The Postscript "eq" operator has to test whether
two PostScript arrays share the same storage, rather than whether they
contain the same values [*]. If you can do (1), you can use Go slices
Hi Ian,
Just out of interest: if I choose that I mean equality 1 (same length and
same underlying storage), how would I perform the test for equality? Does
this require unsafe.Pointer, or is there a more proper way?
All the best,
Jochen
On Sunday 11 August 2024 at 00:08:26 UTC+1 Ian Lance Tay
Thank you!
On Wednesday 7 August 2024 at 07:10:55 UTC+1 wagner riffel wrote:
> Jochen Voss wrote:
> > Now I just want to run one of these sub-benchmarks. I tried -bench
> > '^BenchmarkTextLayout/CFFSimple1$' but this runs two of the benchmarks:
> >
Hello,
In a Go benchmark I use b.Run() to define a number of sub-benchmarks. This
seems to work:
> go test -run=^$ -bench '^BenchmarkTextLayout'
goos: darwin
goarch: arm64
pkg: seehuhn.de/go/pdf/graphics
BenchmarkTextLayout/CFFSimple1-8 49 24061184 ns/op
BenchmarkTextLayout/CFFS
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 &commonHandler{
json: h.json,
opts: h.opts,
preformattedAt
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 Goog
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 pri
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
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 s
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
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/
--
Yo
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, no
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
a smart way of doing it,
>>>
>>> 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 s
Tuesday, 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
>>
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 c
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:
>
> pac
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 := &packages.Config{Mode: packages.LoadSyntax}
initial, err :
nd then 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 (
>> htt
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
questions:
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
x27;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 me
nit
> 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
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://g
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 play
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
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 add
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:
&
ry 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:
> >
> > type V interface {
> > comparable // (1)
> > SomeMethod
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 https://go.
r Galbavy 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
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 t
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 er
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?
- How
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] https://pkg.go.dev/compress/l
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 test
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
>>
>> "
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
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 p
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
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 co
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
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 https:
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" gr
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
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
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
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,
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
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
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
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
ember 17, 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
>> document
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:
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: https://play.golan
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
gt; var duck2 Duck
>
> 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 Mars
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 ni
Hi Владимир,
On Sunday, 26 February 2017 17:06:16 UTC, Владимир Мулько wrote:
>
> Hello, i had similar issue with empty block inserts in Go 1.8,
> after changing {{block "name" .}}{{end}} to {{template "name"}} template
> starts working.
>
It looks like this fixed the issue for me, too. Thanks!
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, se
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: http
62 matches
Mail list logo