docs: document previously implicit formatting rule

Adds a formatting rule to the code style documentation that is being
used widely throughout the codebase but isn't properly documented.
This commit is contained in:
Oliver Gugger committed 2025-05-12 07:00:51 +02:00
1 parent ee25c228e9
commit 12dbeb99c3
1 file changed
+42
+42
View File
@@ -230,6 +230,48 @@ value, err := bar(
)
```
As long as the visual symmetry of the opening and closing parentheses is
preserved, arguments that would otherwise introduce a new level of indentation
are allowed to be written in a more compact form.
Example with inline struct creation:
**ACCEPTABLE**
```go
response, err := node.AddInvoice(
ctx, &lnrpc.Invoice{
Memo: "invoice",
ValueMsat: int64(oneUnitMilliSat - 1),
},
)
```
**PREFERRED**
```go
response, err := node.AddInvoice(ctx, &lnrpc.Invoice{
Memo: "invoice",
ValueMsat: int64(oneUnitMilliSat - 1),
})
```
Example with nested function call:
**ACCEPTABLE**:
```go
payInvoiceWithSatoshi(
t.t, dave, invoiceResp2, withFailure(
lnrpc.Payment_FAILED, failureNoRoute,
),
)
```
**PREFERRED**:
```go
payInvoiceWithSatoshi(t.t, dave, invoiceResp2, withFailure(
lnrpc.Payment_FAILED, failureNoRoute,
))
```
#### Exception for log and error message formatting
**Note that the above guidelines don't apply to log or error messages.** For