golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.73k stars 17.63k forks source link

proposal: error vizualization and variable assing: #54797

Closed edson-dev closed 2 years ago

edson-dev commented 2 years ago

I start work with go for some time already and I really like the language. But a thing keeps annoying me for some time... the main problem for me is the error handler for errors and I know that is a really well-debated point of many people that are developing in go. So I decide to write my idea here just to give my 2 cents for the discussion and if anyone thinks it's interesting we can proceed to make a proposal for that.

i understand that are 2 times in a error, been 1st one identifying and then handling then, so for my development, I keep writing the same code(its just an example... i use log and all, but the idea is the same) or hiding the errors with _(I know that's not best practice, but we need to identify the errors before we handle then).

x, err := y() if err != nil { print(err) } output: unexpected end of JSON input

and its not readable... because I have 3/4 of my lines of code on this error print stuff... so my idea is to have a token like '_', lets call it '~' that when have a value attributed it self print on console log or any other way. That solution will cover all default console log for development and if you need a really error handler it will be in the code like...

propose

x, ~ := y() output: unexpected end of JSON input

seankhliao commented 2 years ago

See https://github.com/golang/go/issues?q=+label%3Aerror-handling+ for all the previous related error handling proposals.

Please use the forums for general discussions

Closing as this does not appear to be a well fleshed out proposal that can be evaluated.