Hacker News new | ask | show | jobs
by insertnickname 2610 days ago
>Secondly why is this really important functionality in `fmt` and not in `error`?

`fmt` already depends on `errors`, and Go does not allow cyclical dependencies, so `errors` would have to reimplement string formatting.

3 comments

Or they could move the machinery into a shared module.

Which already exists incidentally, internal/errinternal was added so errors.New and fmt.Errorf could return the same type.

It does make errors pull the entire formatting machinery, but chances are you're probably using string formatting long before errors so meh…

Why? Go permits mutual recursion, and "go tool link" seems to support separate compilation that would resolve that cycle.
That's not an argument for putting it in fmt.

That's an argument for putting it in the language layer or putting it in its own place.