-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: limit external dependencies #92
Comments
Sounds good to me. |
Consider using github.com/google/go-cmp instead of mewkiz/pkg/diffutil for testing. |
Done as of commit 5aaf037. |
All dependencies have been updated, replaced or removed, as outlined in #92 (comment) The only dependency that has not been removed/replaced is Closing this issue for now. If we start accumulating unsolicited dependencies in the future, feel free to re-open this issue or create a new one. |
If you capture an error value with the '%w' verb and then display the resulting error with '%+v' you do get a stack trace. |
Oh, great to know. I must have missed this. Thanks @sbinet, I'll definitely look into using |
From at least a very quick test, it seems that @sbinet, do you know if its possible to include the full stack trace with package main
import (
"log"
"github.com/pkg/errors"
//errors "golang.org/x/xerrors"
)
func main() {
if err := foo(); err != nil {
log.Fatalf("%+v", err)
}
}
func foo() error {
return errors.New("error message")
}
// pkg/errors:
//
// 2019/12/28 12:23:48 error message
// main.foo
// /home/u/Desktop/go/src/play/aac/main.go:17
// main.main
// /home/u/Desktop/go/src/play/aac/main.go:11
// runtime.main
// /home/u/go/src/runtime/proc.go:203
// runtime.goexit
// /home/u/go/src/runtime/asm_amd64.s:1375
// exit status 1
// x/xerrors:
//
// 2019/12/28 12:20:41 error message:
// main.foo
// /home/u/Desktop/go/src/play/aac/main.go:17
// exit status 1 |
I believe a better example would be something along these lines: https://play.golang.org/p/T7w1Hc15JVZ package main
import (
"io"
"log"
errors "golang.org/x/xerrors"
)
func main() {
if err := foo(); err != nil {
log.Fatalf("%+v", err)
}
}
func foo() error {
err := f1()
if err != nil {
return errors.Errorf("could not foo me: %w", err)
}
return nil
}
func f1() error {
err := f2()
if err != nil {
return errors.Errorf("could not do f1: %w", err)
}
return nil
}
func f2() error {
return errors.Errorf("error message: %w", io.EOF)
}
that said, I don't know whether it's possible to bend |
Yeah, I agree your example is a better showcase of What I'm missing in
Yeah. At least with my current (limited) experience of using To use the terminology of eris, if all root errors where created with When the root error was not created by Creating a new user-defined message to be able to capture more of the stack trace seems like a hack. Sometimes wrapping an error with a user-defined error message is definitely the right thing to do as it adds useful context information. But if the user-defined error message does not add any additional information than the stack trace info (e.g. name of function), then it just adds noise, and limits readability as it becomes more difficult to glance over the code to identify valuable user-defined error messages. As such, I think At least, that's my take on it. The addition of Thanks for taking the time to give more background and examples of Cheers, |
Background (click arrow to expand):
This proposal is in a similar spirit as #73, seeking to limit the external dependencies we rely on for the core of `llir/llvm`. Note, that at least in the initial stage of this proposal, this does not include dependencies required by usage example code (e.g. [asm/example_test.go](https://github.com/llir/llvm/blob/master/asm/example_test.go) depends on `github.com/kr/pretty`). However, for the `llir/llvm` packages we should seek to remove any external dependency that we don't have explicit control over (that is any package not living under `github.com/llir`) or which has not been accepted as canonical packages to use by the Go community. For now, this includes `pkg/errors`, but that is likely to change in Go 1.14 (see #73).To start with, I'd like to copy/fork/implement natural sorting to remove our external dependency on github.com/rickypai/natsort, firstly because the implementation is fairly trivial (natsort/sort.go is 136 lines of code), and secondly and perhaps more importantly
github.com/rickypai/natsort
is the GitHub mirror repo forbitbucket.org/zombiezen/cardcpx
.Going forward, I'd also like for us to implement the policy of not adding external dependencies for the project unless carefully motivated.
Food for thought.
edit: The following external dependencies are currently considered by this proposal:
github.com/rickypai/natsort
(see all: replace rickypai/natsort with internal/natsort #94)As of 2019-06-02, the external dependencies situation is as follows.
To be kept
Used by core during development.
github.com/mewspring/tools
string2enum
tool, the inverse ofstringer
(as used byasm/enum
)golang.org/x/tools
stringer
tool (as used byir/enum
andir/types
)To be kept for test cases
Used by example code and test cases.
To be removed in Go 1.14
Used everywhere.
github.com/pkg/errors
Done
To be moved? (decided not to move)
Used by core.
github.com/mewmew/float
ir/constant
)mewmew/float
tointernal/float
.To be removed?
Used by example code and test cases.
github.com/kr/pretty
(removed in favour of google/go-cmp)github.com/mewkiz/pkg
The text was updated successfully, but these errors were encountered: