-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add numbers to all Errorfs #560
base: master
Are you sure you want to change the base?
Conversation
Hva er mekanismen for å velge en feilkode? Regner med at det ikke er 9776 forskjellige feil i naiserator, så da er det ikke en ren teller ... Kanskje dokumentere hvordan man velger seg en ny feilkode i README? |
Og kanskje også bli enige om hvordan en sånn her feilkode-mekanisme skal virke, og om man skal ha det |
Random uniform sampling on the intervall 0-9999. find . -type f -name "*.go" | while IFS= read -r file; do
awk '{gsub(/fmt\.Errorf\("/, sprintf("fmt.Errorf(\"NAISERATOR-%04d: ", int(rand()*10000)))}1' "$file" > temp && mv temp "$file"
done Paraphrasing from another project where we did this: " Codes also shouldn’t be assigned in order based on the tool’s source code, because this could suggest a misleading pattern, and sequential numbers aren’t visually distinct enough. For tools that have development branches that last a long time, there should be a way to prevent code conflicts between branches. This helps avoid accidentally using the same code twice and reduces the chance of merge conflicts when combining code from different branches. If you're feeling fancy, I use the following for outputting new NNNN numbers as I code: (defun carl-insert-error-number (&optional reroll)
"Generate a random number in the format NNNN with zero padding.
Insert the number at the current cursor position.
If called with a prefix argument (C-u), it will search the project
for the generated number and reroll if the number is found."
(interactive "P")
(let (random-number)
(catch 'reroll
(while t
(setq random-number (format "%04d" (random 10000)))
(if (and reroll
(let ((default-directory (project-root (project-current t))))
(not (string-empty-p (shell-command-to-string
(format "git grep -n %s" random-number))))))
(throw 'reroll random-number))))
(insert random-number) |
Definitively. |
I blanket-awked this instead of finding the useful ones.
6231656
to
f3ea709
Compare
I did it over all fmt.Errorfs instead of finding the useful ones 🙃