Radar · Go · Archive · Week 29 · Jul 13 – 19, 2026
cmd/gofmt: don't rewrite into smart quotes
Nice to knowtooling
- What changed
go fmtandgo docwill no longer convert plain quotes into smart quotes.- Production impact
- The source does not say.
- Try it
- Run
go fmton a file that contains straight quotes and observe that they are preserved. - Source
- github.com/golang/go/issues/76975
Understand it, then run it
go fmt used to replace plain quotation marks in comments with “smart” quotes. The change stops that conversion. Now the text you write in a comment stays exactly as you typed it. This means your source files no longer contain invisible “fancy” characters that were added automatically.
Run it now
// This program shows that go/format no longer rewrites plain quotes into smart quotes.
// It formats a source string that contains smart quotes and prints the result unchanged.
package main
import (
"fmt"
"go/format"
)
func main() {
// Source code with smart quotes (U+201C and U+201D) in a comment.
src := []byte(`package main
// “Hello, world!” – a comment with smart quotes
func main() {}`)
// Format the source. If smart quotes were rewritten, the output would differ.
formatted, err := format.Source(src)
if err != nil {
fmt.Println("format error:", err)
return
}
// Print the formatted source to show that smart quotes are preserved.
fmt.Println(string(formatted))
}
What it printed when we ran it on Go 1.27.1
package main
// “Hello, world!” – a comment with smart quotes
func main() {}
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed