Re: [go-nuts] Underlying type constraints and pointers

2022-10-21 Thread 'Axel Wagner' via golang-nuts
Sorry, I literally just fell out of bed, so I jumped on the first thing I saw, which probably isn't the most helpful answer. You might be interested in this sentence from the Go 1.18 release notes : The Go compiler does not support accessing a struct field x.f w

Re: [go-nuts] Underlying type constraints and pointers

2022-10-21 Thread 'Axel Wagner' via golang-nuts
(or, for convenience, you can use a type alias `type foo = struct{ data []string }`, which should allow you to write ~foo. On Sat, Oct 22, 2022 at 7:11 AM Axel Wagner wrote: > > > On Sat, Oct 22, 2022 at 1:40 AM 'Aaron Beitch' via golang-nuts < > golang-nuts@googlegroups.com> wrote: > >> I have

Re: [go-nuts] Underlying type constraints and pointers

2022-10-21 Thread 'Axel Wagner' via golang-nuts
On Sat, Oct 22, 2022 at 1:40 AM 'Aaron Beitch' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I have types Foo and Bar. Bar's underlying type is Foo. > The underlying type is defined recursively and always either a predeclared type (int, string…), or a type literal. The underlying type

[go-nuts] Underlying type constraints and pointers

2022-10-21 Thread 'Aaron Beitch' via golang-nuts
Hello, I would like to provide some helper functions that work on pointer types and having trouble getting it to work with ~ type constraints. Here is the problem in code: https://go.dev/play/p/z0sKEsUaL_d I have types Foo and Bar. Bar's underlying type is Foo. I want a function that takes in

Re: [go-nuts] Error Handling Question

2022-10-21 Thread Ian Lance Taylor
On Fri, Oct 21, 2022 at 12:30 PM Daniel Lepage wrote: > > > In that issue there was considerable resistance to having flow of control > > change as part of an expression. No other part of Go works that way: flow > > of control change is always a keyword, or a call to panic which can only > > oc

[go-nuts] Re: Replace reference path

2022-10-21 Thread Amnon
try https://pkg.go.dev/golang.org/x/tools/cmd/gomvpkg On Friday, 21 October 2022 at 16:58:57 UTC+1 mr@gmail.com wrote: > I'm looking for a tool like this, I've searched google and github and > can't find one, have you guys used such a tool? > > I use a method like this in my code > > k8s.io

Re: [go-nuts] Error Handling Question

2022-10-21 Thread 'Daniel Lepage' via golang-nuts
On Fri, Oct 21, 2022 at 5:57 PM Andrew Harris wrote: > Comparing 'panic' and 't.Fatal', they are similar in that there's no > notion of recovering and making further progress, they abruptly terminate > the process. Still, a wonky thing to say is that a 't.Fatal' call is > completely legitimate as

Re: [go-nuts] Error Handling Question

2022-10-21 Thread 'Daniel Lepage' via golang-nuts
On Fri, Oct 21, 2022 at 5:16 PM Robert Engels wrote: > Unchecked exceptions in Java denote programming errors or critical > unrecoverable errors. > Yes, that's exactly what I'm saying. This is what panics are used for in Go; if you have an error that is recoverable you ought to be returning an e

Re: [go-nuts] Error Handling Question

2022-10-21 Thread Andrew Harris
Comparing 'panic' and 't.Fatal', they are similar in that there's no notion of recovering and making further progress, they abruptly terminate the process. Still, a wonky thing to say is that a 't.Fatal' call is completely legitimate as a form of "checked"-style error handling. It will log what

Re: [go-nuts] Error Handling Question

2022-10-21 Thread Robert Engels
Unchecked exceptions in Java denote programming errors or critical unrecoverable errors. If these are being trapped/handled it is indicative of a system with design errors. (That being said, some programming errors can be ignored/handled at the request level - indicating that the chance any

Re: [go-nuts] Error Handling Question

2022-10-21 Thread 'Daniel Lepage' via golang-nuts
> That aspect of this idea seems similar to the try proposal ( https://go.dev/issue/32437). Yes, I read over that proposal and the comments; it seemed like the biggest objections were: 1. handle() is very similar to defer/recover but not quite the same, which could be confusing (e.g. that a defer(

Re: [go-nuts] Error Handling Question

2022-10-21 Thread Ian Lance Taylor
On Thu, Oct 20, 2022 at 9:52 PM Daniel Lepage wrote: > > Sorry, I should have been clearer - what I am proposing is both try/handle > blocks and a `check` expression that triggers the handler. Sorry, I did miss the "check". That aspect of this idea seems similar to the try proposal (https://go.

[go-nuts] Replace reference path

2022-10-21 Thread mr....@gmail.com
I'm looking for a tool like this, I've searched google and github and can't find one, have you guys used such a tool? I use a method like this in my code k8s.io/apimachinery/pkg/util/diff.ObjectReflectDiff k8s.io/apimachinery/pkg/util/diff is his import path, later I want to switch to another

[go-nuts] Analyse postgresql error

2022-10-21 Thread David Harel
Hi there, Newbie on golang. Using sqlc: https://github.com/kyleconroy/sqlc in the environment created by Karl Keefer: https://github.com/karlkeefer/pngr/actions/workflows/build.yml, thanks Karl. My queries use querier which is auto generated by sqlc. Sometime I get an error result in my query s