Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The error type in go is literally just a string

No, like I said before, it's literally an interface. Hell, your next line even proves it. If it were a string, it would be defined as:

    type error string
But as you've pointed out yourself, that's not its definition at all.

> So i dont know what your talking about then.

I guess that's what happens when you don't even have a basic understanding of programming. Errors are intended to be complex types; to capture all the relevant information that pertains to the error. https://go.dev/play/p/MhQY_6eT1Ir At very least a sentinel value. If your error is just a string, you're doing something horribly wrong — or, charitably, trying to shoehorn Go into scripting tasks. But in that case you'd use Go's exception handlers, which bundles the stack trace and all alongside the string, so... However, if your workload is script in nature, why not just use Python? That's what it was designed for. Different tools for different jobs.





This guy can't help his self except to act like an ass

It is always curious when a comment on the internet is anthropomorphized. Where is the logic found in that?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: