Skip to content

Commit 8044891

Browse files
authored
Merge pull request #9799 from guggero/function-call-formatting
docs: document previously implicit formatting rule
2 parents ee25c22 + 12dbeb9 commit 8044891

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/development_guidelines.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,48 @@ value, err := bar(
230230
)
231231
```
232232
233+
As long as the visual symmetry of the opening and closing parentheses is
234+
preserved, arguments that would otherwise introduce a new level of indentation
235+
are allowed to be written in a more compact form.
236+
237+
Example with inline struct creation:
238+
239+
**ACCEPTABLE**
240+
```go
241+
response, err := node.AddInvoice(
242+
ctx, &lnrpc.Invoice{
243+
Memo: "invoice",
244+
ValueMsat: int64(oneUnitMilliSat - 1),
245+
},
246+
)
247+
```
248+
249+
**PREFERRED**
250+
```go
251+
response, err := node.AddInvoice(ctx, &lnrpc.Invoice{
252+
Memo: "invoice",
253+
ValueMsat: int64(oneUnitMilliSat - 1),
254+
})
255+
```
256+
257+
Example with nested function call:
258+
259+
**ACCEPTABLE**:
260+
```go
261+
payInvoiceWithSatoshi(
262+
t.t, dave, invoiceResp2, withFailure(
263+
lnrpc.Payment_FAILED, failureNoRoute,
264+
),
265+
)
266+
```
267+
268+
**PREFERRED**:
269+
```go
270+
payInvoiceWithSatoshi(t.t, dave, invoiceResp2, withFailure(
271+
lnrpc.Payment_FAILED, failureNoRoute,
272+
))
273+
```
274+
233275
#### Exception for log and error message formatting
234276
235277
**Note that the above guidelines don't apply to log or error messages.** For

0 commit comments

Comments
 (0)