[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread 'Mark' via golang-nuts
I finally worked out how to make my go-diff pkg (v1.1.0) able to diff sequences of structs based on a key function. On Friday, July 14, 2023 at 12:27:46 PM UTC+1 Mark wrote: > Hi Brian, > Ah, thank you, that helped a lot. > > On Friday,

[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-14 Thread Howard C. Shaw III
Such an issue is what I linked you to earlier in the thread. So I do not think you need to create a new issue - however, in the comments in that issue one of the devs asks for use cases where go work sync is not sufficient, so you might want to reply to that with your example where go work

[go-nuts] Go 1.21 Release Candidate 3 is released

2023-07-14 Thread announce
Hello gophers, We have just released go1.21rc3, a release candidate version of Go 1.21. It is cut from release-branch.go1.21 at the revision tagged go1.21rc3. Please try your production load tests and unit tests with the new version. Your help testing these pre-release versions is invaluable.

Re: [go-nuts] recover from a unexpected fault address

2023-07-14 Thread XL T
my case is what Robert said. code below could cause this err, and not recover by go: --- s := "123" sh := *(*reflect.StringHeader)(unsafe.Pointer()) b := []byte{} bh := (*reflect.SliceHeader)(unsafe.Pointer()) bh.Data,

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread 'Mark' via golang-nuts
Hi Brian, Ah, thank you, that helped a lot. On Friday, July 14, 2023 at 11:54:51 AM UTC+1 Brian Candler wrote: > The 'diff' package you showed identifies the changed object index by means > of a "Path" attribute in the Changelog entry. If the top level object is a > slice, then

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread Brian Candler
The 'diff' package you showed identifies the changed object index by means of a "Path" attribute in the Changelog entry. If the top level object is a slice, then Atoi(change.Path[0]) is the index into the slice. On Friday, 14 July 2023 at 10:47:47 UTC+1 Mark wrote: > Hi Brian, > Your code

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread 'Mark' via golang-nuts
Hi Brian, Your code certainly identifies the different items. However, that's not a diff tool in the sense I mean. Unix diff and tools like it don't just say x[i] != y[i], they find the longest common subsequences and in essence produce a series of edit commands that would turn slice x into

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread Brian Candler
I forgot you wanted generics: https://go.dev/play/p/PhGVjsWWTdB On Friday, 14 July 2023 at 09:47:21 UTC+1 Brian Candler wrote: > You seem to be saying "if the S field is different then I want to consider > these two structs different, and get pointers to the two structs. If the S > field is

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread Brian Candler
You seem to be saying "if the S field is different then I want to consider these two structs different, and get pointers to the two structs. If the S field is the same then I want to skip the pair entirely". Is that right? The required semantics are not entirely clear, but it sounds like a

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread 'Mark' via golang-nuts
In fact the diff pkg mentioned above does work but is of no use to me since for each change it gives back only the field(s) used, not the original structs (or pointers to them), so I can't see any way back to the original structs (or their slice indexes). On Friday, July 14, 2023 at 8:58:41 AM

[go-nuts] Re: I made a CLI tool, and I'm curious about your ideas

2023-07-14 Thread Marcello H
No matter what other people say, as a first project, I think it is great because it gives you the opportunity to practise how a project is made. I doubt if I would use it since it is done by hand almost at the same speed. Also, I don't like the idea that it forces me into a certain layout. So the

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread 'Mark' via golang-nuts
What I really want to do is to be able to diff slices of structs on the basis of one single field. For example, given: ``` type Item struct { I int S string } ``` and given `a` and `b` are both of type`[]Item`, I want to diff these slices based purely on the `S` field, ignoring the `I`

[go-nuts] Re: Can a struct be made comparable?

2023-07-14 Thread Peter Galbavy
As a slight digression - I thought I was going mad, but 'slices' and 'maps' are new :-) Only in 1.21 though... Well, there is a lot of boiler plate that maps.Keys() will get rid of. On Thursday, 13 July 2023 at 10:06:01 UTC+1 Brian Candler wrote: > Structs are already comparable, but all

[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-14 Thread Jan
Still on the topic, if I have to use `go.mod` replace clauses, what is the point of `go.work` ? Notice replace in `go.work` doesn't work. Any thoughts if it would be appropriate to create an issue to add workspace support for `go get` ? cheers On Wednesday, July 12, 2023 at 12:48:57 AM UTC+2