Skip to main content

WithIndent

Adds an additional indentation level to the context. It retrieves the current indentation level from the context, appends the provided additional indent string, and returns a new context with the updated indentation level.

def WithIndent(
ctx: context.Context,
additionalIndent: string
) - > context.Context

Adds an additional indentation level to the provided context. This function is used to manage and propagate indentation settings across different parts of an application, typically for logging or structured output.

Parameters

NameTypeDescription
ctxcontext.ContextThe context to which the additional indentation will be applied. This context should ideally contain an existing indentation level.
additionalIndentstringThe string representing the additional indentation to be added to the current indent level. For example, " " for two spaces or "\t" for a tab.

Returns

TypeDescription
context.ContextA new context derived from the input context, with the updated indentation level.