snapshot of https://github.com/uber-go/guide.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
23
src/string-escape.md
Normal file
23
src/string-escape.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Use Raw String Literals to Avoid Escaping
|
||||
|
||||
Go supports [raw string literals](https://go.dev/ref/spec#raw_string_lit),
|
||||
which can span multiple lines and include quotes. Use these to avoid
|
||||
hand-escaped strings which are much harder to read.
|
||||
|
||||
<table>
|
||||
<thead><tr><th>Bad</th><th>Good</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>
|
||||
|
||||
```go
|
||||
wantError := "unknown name:\"test\""
|
||||
```
|
||||
|
||||
</td><td>
|
||||
|
||||
```go
|
||||
wantError := `unknown error:"test"`
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody></table>
|
||||
Reference in New Issue
Block a user