-
Notifications
You must be signed in to change notification settings - Fork 18k
builtin: trace function #6069
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
Labels
Milestone
Comments
No need to put _into the_ language a new built-int for what can be _expressed by the_ language already. #Reject ---- package foo_test import ( "fmt" "path" "runtime" ) func trace(s string, va ...interface{}) { _, fn, fl, _ := runtime.Caller(1) fmt.Printf("%s:%d: ", path.Base(fn), fl) fmt.Printf(s, va...) fmt.Println() } ---- - Now you can write debug prints, to be printed during tests, like trace("%v %i", myVar, i) - No need to import/unimport anything. - You cannot forget to remove the debug prints before building the binary, because as long as they are present in the source, the build will fail. It will build only when doing $ go test |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: