Hi,
I have a codebase which uses go-swagger <https://github.com/go-swagger/go-swagger> to parse comments in Go files and generate swagger documentation. I recently upgraded to Go 1.19, and found that gofmt’s behavior formats comments in a way which breaks go-swagger. For example this code: package somepackage import ( "encoding/json" "fmt" "io" "net/http" "strconv" "time" ) // SomeFunc do something//// swagger:operation POST /api/v1/somefunc someFunc//// Do something//// ---// x-codeSamples:// - lang: 'curl'// source: |// curl -u "${LOGIN}:${PASSWORD}" -d '{"key": "value"}' -X POST "https://{host}/api/v1/somefunc"// curl -u "${LOGIN}:${PASSWORD}" -d '{"key2": "value2"}' -X POST "https://{host}/api/v1/somefunc"// responses:// '200':// description: "Some func"// examples:// application/json:// key: "value"// '400':// $ref: "#/responses/ErrorResponse"// '503':// $ref: "#/responses/ErrorResponse"func SomeFunct(rw http.ResponseWriter, req *http.Request) { /// do something } Gets reformatted as: package somepackage import ( "encoding/json" "fmt" "io" "net/http" "strconv" "time" ) // SomeFunc do something // // swagger:operation POST /api/v1/somefunc someFunc // // # Do something // // --- // x-codeSamples: // - lang: 'curl' // source: | // curl -u "${LOGIN}:${PASSWORD}" -d '{"key": "value"}' -X POST "https://{host}/api/v1/somefunc" // curl -u "${LOGIN}:${PASSWORD}" -d '{"key2": "value2"}' -X POST "https://{host}/api/v1/somefunc" // // responses: // // '200': // description: "Some func" // examples: // application/json: // key: "value" // '400': // $ref: "#/responses/ErrorResponse" // '503': // $ref: "#/responses/ErrorResponse" func SomeFunct(rw http.ResponseWriter, req *http.Request) { /// do something } Specifically the lines under source: | get re-indented in such a way that the YAML is invalid, and go-swagger fails to process this file. This issue has been raised in the go-swagger community: https://github.com/go-swagger/go-swagger/issues/2759 but I don’t think this can be worked around in go-swagger, since go-swagger parses the .go files after they have been formatted by gofmt and written to disk. Can anyone suggest a possible workaround, or a bugfix to gofmt? Thanks. — Craig -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d6abf372-4cb1-4070-8a62-d4c6c6ba6bcen%40googlegroups.com.