How to Use Compiler Directives (//go

noinline, //go:nosplit)

Use //go:noinline and //go:nosplit directives before a function to control compiler inlining and stack growth behavior.

Use //go:noinline to prevent the compiler from inlining a function and //go:nosplit to prevent the stack from growing during execution. Place these directives on their own line immediately before the function declaration.

//go:noinline
func NoInlineFunc() {
	// Function body
}

//go:nosplit
func NoSplitFunc() {
	// Function body
}