-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fmt cmd: use a tab instead of two spaces to format comments #1386
Conversation
Codecov ReportBase: 95.71% // Head: 95.71% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #1386 +/- ##
=======================================
Coverage 95.71% 95.71%
=======================================
Files 14 14
Lines 2826 2826
=======================================
Hits 2705 2705
Misses 66 66
Partials 55 55
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
LGTM
Maybe should update the prefix space to tab but keep use space afterwards. |
With this change, I think using one space is better here since most people have their editors and IDEs configured to display tabs as multiples of 2 spaces, which looks off for 2 and - in my opinion - wastes screen real estate if we format comments with a tab displayed as 4 or 8 spaces. While go does use tabs for code indentation, one space after the I would therefore like to either revert this change or ideally have it configurable to use either a tab or a space. What do you think? |
@morremeyer
|
@morremeyer |
Maybe add a setting file and allow user set format style? |
@sdghchj Can I assume that you're referencing go 1.16 and go 1.19 respectively? While I wouldn't want to break compatibility with go 1.17 (even though it is not supported anymore) since 1.18 is only out for ~6 months, breaking compatiblity with 1.6 or 1.9 should not be an issue, should it? |
Sorry, I have not got your point. I just have no better idea to fix it regarding all the preferences. |
@sdghchj You mentioned go 1.6 and go 1.9 in your previous comment. Those versions of go are end of life for a while now, I do not see any problem in breaking compatibility with them. I have researched this topic now and I think that swag is doing the right think here by using new features that are available with go 1.19. This issue needs to be fixed in gofumpt which is breaking the correct formatting of I opened mvdan/gofumpt#254 to track that. Thanks for your input and help here! |
I have continued to analyze this issue. The problem is neither with It is simply that with the new documentation behaviour in 1.19, you cannot have indented documentation without some non-indented documentation. I had // @Summary Create category
// @Description Creates a new category
// @Tags Categories
// @Produce json
// @Success 201 {object} CategoryResponse
// @Failure 400 {object} httperrors.HTTPError
// @Failure 404
// @Failure 500 {object} httperrors.HTTPError
// @Param category body models.CategoryCreate true "Category"
// @Router /v1/categories [post]
func (co Controller) CreateCategory(c *gin.Context) { which is not correctly formatted. It therefore gets re-formatted by With // CreateCategory creates a new category
//
// @Summary Create category
// @Description Creates a new category
// @Tags Categories
// @Produce json
// @Success 201 {object} CategoryResponse
// @Failure 400 {object} httperrors.HTTPError
// @Failure 404
// @Failure 500 {object} httperrors.HTTPError
// @Param category body models.CategoryCreate true "Category"
// @Router /v1/categories [post]
func (co Controller) CreateCategory(c *gin.Context) { this does not happen. |
Describe the PR
change fmt cmd: use a tab instead of two spaces at the front of a comment line, to be compatibale with gofmt v1.19.
Relation issue
#1381