01_basic_component

command
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Flora Example: Basic Component Auto-Wiring

This example demonstrates the absolute core of the Flora DI framework: Zero-configuration auto-wiring.

The Concept

Normally, you would have to manually instantiate your dependencies and pass them into your constructors. With Flora, you simply embed the flora.Component tag into your structs.

Flora will automatically:

  1. Discover the struct.
  2. Find its constructor (New...).
  3. Notice that App requires a Greeter interface.
  4. Automatically bind EnglishGreeter to the Greeter interface because it is the only implementation.
  5. Generate the boilerplate code to wire them together.

How to run

  1. Generate the DI container (flora_container.go) in the current directory:
    flora gen -o .
    
    

2. Run the application:
```bash
go run .

Expected Output

Starting the application...
Hello! Flora has successfully injected this component.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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