Documentation
¶
Index ¶
Constants ¶
View Source
const ( Version = "0.10.19" SupportedTemplVersion = "v0.3.960" )
Variables ¶
This section is empty.
Functions ¶
func PrintVersionInfoAndExit ¶ added in v0.5.0
func PrintVersionInfoAndExit()
Types ¶
type CmdStr ¶
type CmdStr string
func (*CmdStr) UnmarshalText ¶
type Config ¶
type Config struct {
// Compiler defines optional Go compiler flags
Compiler *ConfigCompiler `yaml:"compiler"`
App ConfigApp `yaml:"app"`
// Log specifies logging related configurations.
Log ConfigLog `yaml:"log"`
// Debounce is the file watcher debounce duration.
Debounce time.Duration `yaml:"debounce"`
// ProxyTimeout defines for how long the proxy must try retry
// requesting the application server when receiving connection refused error.
ProxyTimeout time.Duration `yaml:"proxy-timeout"`
// Lint runs golangci-lint before building if enabled.
Lint bool `yaml:"lint"`
// Format enables running `templ fmt` on `.templ` file changes.
Format bool `yaml:"format"`
// TemplierHost is the Templiér HTTP server host address.
// Example: "127.0.0.1:9999".
TemplierHost string `yaml:"templier-host" validate:"url,required"`
// TLS is optional, will serve HTTP instead of HTTPS if nil.
TLS *struct {
Cert string `yaml:"cert" validate:"filepath,required"`
Key string `yaml:"key" validate:"filepath,required"`
} `yaml:"tls"`
// CustomWatchers defines custom file change watchers.
CustomWatchers []ConfigCustomWatcher `yaml:"custom-watchers"`
}
func (*Config) CompilerEnv ¶ added in v0.9.0
func (*Config) CompilerFlags ¶ added in v0.9.0
type ConfigApp ¶
type ConfigApp struct {
// DirSrcRoot is the source root directory for the application server.
DirSrcRoot string `yaml:"dir-src-root" validate:"dirpath,required"`
// Exclude defines glob expressions to match files exluded from watching.
Exclude GlobList `yaml:"exclude"`
// DirCmd is the server cmd directory containing the `main` function.
DirCmd string `yaml:"dir-cmd" validate:"dirpath,required"`
// DirWork is the working directory to run the application server from.
DirWork string `yaml:"dir-work" validate:"dirpath,required"`
// Flags are the CLI arguments to be passed to the application server.
Flags SpaceSeparatedList `yaml:"flags"`
// Host is the application server host address.
// Example: "https://local.example.com:8080"
Host URL `yaml:"host" validate:"required"`
// contains filtered or unexported fields
}
func (*ConfigApp) DirSrcRootAbsolute ¶
type ConfigCompiler ¶ added in v0.9.0
type ConfigCompiler struct {
// Gcflags is the -gcflags compiler flags to be passed to the go
// compiler when compiling the application server.
Gcflags string `yaml:"gcflags"`
// Ldflags provides the -ldflags CLI argument to Go compiler
// to pass on each go tool link invocation.
Ldflags string `yaml:"ldflags"`
// Asmflags is equivalent to `-asmflags '[pattern=]arg list'`.
Asmflags string `yaml:"asmflags"`
// Tags lists additional build tags to consider satisfied during the build.
Tags []string `yaml:"tags"`
// Race sets `-race` when true.
Race bool `yaml:"race"`
// Trimpath sets `-trimpath` when true.
Trimpath bool `yaml:"trimpath"`
// Msan sets `-msan` when true.
Msan bool `yaml:"msan"`
// P sets the number of programs, such as build commands that can be run in
// parallel. The default is GOMAXPROCS, normally the number of CPUs available.
P uint32 `yaml:"p"`
// Env passes environment variables to the Go compiler.
Env map[string]string `yaml:"env"`
// contains filtered or unexported fields
}
type ConfigCustomWatcher ¶
type ConfigCustomWatcher struct {
// Name is the display name for the custom watcher.
Name TrimmedString `yaml:"name"`
// Include specifies glob expressions for what files to watch.
Include GlobList `yaml:"include"`
// Exclude specifies glob expressions for what files to ignore
// that would otherwise match `include`.
Exclude GlobList `yaml:"exclude"`
// Cmd specifies the command to run when an included file changed.
// Cmd will be executed in app.dir-work. This is optional and can be left empty
// since sometimes all you want to do is rebuild & restart or just restart
// the server, such as when a config file changes.
Cmd CmdStr `yaml:"cmd"`
// FailOnError specifies that in case cmd returns error code 1 the output
// of the execution should be displayed in the browser, just like
// for example if the Go compiler fails to compile.
FailOnError bool `yaml:"fail-on-error"`
// Debounce defines how long to wait for more file changes
// after the first one occurred before executing cmd.
// Default debounce duration is applied if left empty.
Debounce time.Duration `yaml:"debounce"`
// Requires defines what action is required when an included file changed.
// Accepts the following options:
//
// - "" (or simply keep the field empty): no action, just execute Cmd.
// - "reload": Requires browser tabs to be reloaded.
// - "restart": Requires the server process to be restarted.
// - "rebuild": Requires the server to be rebuilt and restarted.
//
// This option overwrites regular behavior (for non-templ file changes it's "rebuild")
Requires Requires `yaml:"requires"`
}
func (ConfigCustomWatcher) Validate ¶
func (w ConfigCustomWatcher) Validate() error
type ConfigLog ¶ added in v0.7.0
type ConfigLog struct {
// Level accepts either of:
// - "": empty string is the same as "erronly"
// - "erronly": error logs only.
// - "verbose": verbose logging of relevant events.
// - "debug": verbose debug logging.
Level LogLevel `yaml:"level"`
// ClearOn accepts either of:
// - "": disables console log clearing.
// - "restart": clears console logs only on app server restart.
// - "file-change": clears console logs on every file change.
ClearOn LogClear `yaml:"clear-on"`
// PrintJSDebugLogs enables Templiér injected javascript
// debug logs in the browser.
PrintJSDebugLogs bool `yaml:"print-js-debug-logs"`
}
type LogLevel ¶ added in v0.7.0
func (*LogLevel) UnmarshalText ¶ added in v0.7.0
type Requires ¶
func (*Requires) UnmarshalText ¶
type SpaceSeparatedList ¶
type SpaceSeparatedList []string
func (*SpaceSeparatedList) UnmarshalText ¶
func (l *SpaceSeparatedList) UnmarshalText(t []byte) error
type TrimmedString ¶ added in v0.7.4
type TrimmedString string
TrimmedString removes all leading and trailing white space, as defined by Unicode, when parsing from text as TextUnmarshaler.
func (*TrimmedString) UnmarshalText ¶ added in v0.7.4
func (t *TrimmedString) UnmarshalText(text []byte) error
Click to show internal directories.
Click to hide internal directories.