contextscan

package
v0.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package contextscan names the package-level functions in a directory whose first parameter is a context.Context.

Both paths that compile a template use it: the generator, for a templates package, and routetree, for a route package. They share it so one definition decides what counts as a context-taking external, and so a declaration means the same thing wherever it is written.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Externals

func Externals(dir string) (map[string]bool, error)

Externals names the package-level functions in dir whose first parameter is a context.Context.

An external is an ordinary Go function, so the template declaration says nothing about a context. Reading the implementation lets a function that needs one receive it without a second declaration form: write the parameter and it is passed, leave it out and the function is called plainly.

An async external gets the boundary's context, which is what lets a call that can abort observe cancellation. A synchronous one gets the render context at the position it occupies, which is what lets a value belonging to the request — a CSRF token, a nonce — render inline without travelling through the parameter struct of every page that needs it.

Detection is syntactic on purpose. It runs before the package compiles, so a file that does not parse is skipped rather than failing generation; a call shape that then does not match is an ordinary Go compile error at the generated call site.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL