this post was submitted on 02 Mar 2025
8 points (100.0% liked)
Golang
2349 readers
1 users here now
This is a community dedicated to the go programming language.
Useful Links:
Rules:
- Posts must be relevant to Go
- No NSFW content
- No hate speech, bigotry, etc
- Try to keep discussions on topic
- No spam of tools/companies/advertisements
- It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I personally try to avoid deeply nested if/else. Or else in general, because I think it makes code more readable. Especially when one of the branches is just an exit condition.
is way more readable than
In a loop, you can just return the value instead of passing it to a "retVal" variable.
With those in mind, you could refactor HasPermissions to
The same could be applied to LoadJSONFile and I think that really would approve the readability and maintainability of your code.
edit: This refactor is not tested