Examples
Weaver ships several example projects in the repository's examples directory, ready to be used as starting points for new projects.
hello — Hello World
The most basic example, demonstrating component definition, dependency injection and the full lifecycle:
main.go: the main application, referencing theUserandChatcomponentsuser/: the User component implementationchat/: the Chat component implementationweaver.yaml/weaver.toml: config files in both formats
bash
cd examples/hello
go run . -conf weaver.yamldemo — Multi-Component Demo
A more complex example with multiple components, a sub-package component and configuration:
main.go: the main applicationwechat/: a component in its own package, demonstrating cross-package referencesetc/: config files
bash
cd examples/demo
go run . -conf etc/weaver.yamltemplate — Project Template
A minimal project template — the recommended starting point for new projects:
main.go: main application skeletonweaver.yaml/weaver.toml: config file skeletons