-
Notifications
You must be signed in to change notification settings - Fork 1
feat: adding uber style guidelines #48
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
base: main
Are you sure you want to change the base?
Conversation
I added |
Ok, I was checking what else to add, and to be honest, I don't know if more rules can be covered, any idea @ccoVeille ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are your homework
- [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) | ||
- [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) | ||
- [Format Strings outside Printf](https://github.com/uber-go/guide/blob/master/style.md#format-strings-outside-printf) | ||
- [Naming Printf-style Functions](https://github.com/uber-go/guide/blob/master/style.md#naming-printf-style-functions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something for this in revive, go vet, or go-critic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry @ccoVeille I don't understand the up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry. I'm used them to point the attention in them.
Here is Gemini explanation about "up"
To bring the thread "up" in the list: In forums, messaging apps, or other discussion platforms, threads often get pushed down as new posts are made. Typing "up" or "bump" is a way to make a new post in that thread, which in turn brings it back to the top of the list of active discussions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
what do you think about merging it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some remaining comments to address.
I'm fine with merging it as-is if you want. But I would prefer if they could be referenced in an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is still needed
- [Receivers and Interfaces](https://github.com/uber-go/guide/blob/master/style.md#receivers-and-interfaces) | ||
- [Zero-value Mutexes are Valid](https://github.com/uber-go/guide/blob/master/style.md#zero-value-mutexes-are-valid) | ||
- [Copy Slices and Maps at Boundaries](https://github.com/uber-go/guide/blob/master/style.md#copy-slices-and-maps-at-boundaries) | ||
- [Defer to Clean Up](https://github.com/uber-go/guide/blob/master/style.md#defer-to-clean-up) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer should be enabled in revive and documentation should mention it
uberstyle/README.md
Outdated
- [x] [Error Wrapping](https://github.com/uber-go/guide/blob/master/style.md#error-wrapping) - Sytle applied through `errorlint` | ||
- [x] [Error Naming](https://github.com/uber-go/guide/blob/master/style.md#error-naming) - Style applied through `errname` | ||
- [Handle Errors Once](#handle-errors-once) | ||
- [Handle Type Assertion Failures](#handle-type-assertion-failures) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
- [Start Enums at One](https://github.com/uber-go/guide/blob/master/style.md#start-enums-at-one) | ||
- [Use `"time"` to handle time](https://github.com/uber-go/guide/blob/master/style.md#use-time-to-handle-time) | ||
- [Errors](https://github.com/uber-go/guide/blob/master/style.md#errors) | ||
- [Error Types](https://github.com/uber-go/guide/blob/master/style.md#error-types) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
- [No goroutines in `init()`](https://github.com/uber-go/guide/blob/master/style.md#no-goroutines-in-init) | ||
- [Performance](https://github.com/uber-go/guide/blob/master/style.md#performance) | ||
- [x] [Prefer strconv over fmt](https://github.com/uber-go/guide/blob/master/style.md#prefer-strconv-over-fmt) - Style applied through `perfsprint` | ||
- [Avoid repeated string-to-byte conversions](https://github.com/uber-go/guide/blob/master/style.md#avoid-repeated-string-to-byte-conversions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
- [Style](https://github.com/uber-go/guide/blob/master/style.md#style) | ||
- [x] [Avoid overly long lines](https://github.com/uber-go/guide/blob/master/style.md#avoid-overly-long-lines) - Style applied through `lll` | ||
- [Be Consistent](https://github.com/uber-go/guide/blob/master/style.md#be-consistent) | ||
- [Group Similar Declarations](https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
uberstyle/README.md
Outdated
- [x] [Avoid overly long lines](https://github.com/uber-go/guide/blob/master/style.md#avoid-overly-long-lines) - Style applied through `lll` | ||
- [Be Consistent](https://github.com/uber-go/guide/blob/master/style.md#be-consistent) | ||
- [Group Similar Declarations](https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations) | ||
- [Import Group Ordering](https://github.com/uber-go/guide/blob/master/style.md#import-group-ordering) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goimport might be enough, otherwise gci might be needed
- [Initializing Struct References](https://github.com/uber-go/guide/blob/master/style.md#initializing-struct-references) | ||
- [Initializing Maps](https://github.com/uber-go/guide/blob/master/style.md#initializing-maps) | ||
- [Format Strings outside Printf](https://github.com/uber-go/guide/blob/master/style.md#format-strings-outside-printf) | ||
- [Naming Printf-style Functions](https://github.com/uber-go/guide/blob/master/style.md#naming-printf-style-functions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
I added revive.defer, but the uber rule is more about, don't forget to defer, and the revive.defer rule is to prevent defer mistakes, right? |
That's right indeed. There are some linters about adding closer when needed. I don't remember which one |
I added |
I feel like I will add the things I requested and ask you to review. But I'm unsure when |
Skeleton to create a
.golangci-lint.yml
with Uber Style Guidelines.