Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: encoding/json: fluent interface for SetIndent/SetEscapeHTML #33051
In the stdlib, it's defined as:
I suggest to make it fluent by:
So that it is more convenient to do this:
Changing the method signature at this point would break the Go 1 compatibility guarantee (https://golang.org/doc/go1compat).
As a pure style point, Go code tends to use fluent interfaces less than in some other languages, in part because fluent interfaces don't work in Go for functions/methods that need to return errors.
OK, I am curious why this would break compatiblity?
If a function returns 1 variable, you now return 2, or none, that's a break of compatibility, but if the function originally returns nothing, now you return one (or any more) that will not affect any existing code?