swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.77k stars 1.2k forks source link

Skipping overwrite in some case but should do. #1914

Closed 0daryo closed 4 weeks ago

0daryo commented 4 weeks ago

Describe the bug Formatter can skip overwriting file when contents are modified and contents are mutated. Cause append can modify its pointer value. e.g. enough cap capacity. https://github.com/swaggo/swag/blob/10f006f392f241444a0903b455111136f0385fbf/formatter.go#L93 To Reproduce Steps to reproduce the behavior:

  1. Run test code with annotation below.(only space between // and @ should be fixed. the rest are formatted.) Format Skipped.
    // @Summary     Add a new pet to the store

    https://github.com/swaggo/swag/pull/1915#discussion_r1814888258

  2. Fail.

Expected behavior Always compare original file and formatted file exactly.

Your swag version e.g. 1.6.3

Your go version e.g. go1.22.0

Desktop (please complete the following information):

Additional context Add any other context about the problem here.