Getting Started
EinarCLI is a command-line interface tool that makes application development easier. It automates complex tasks, generates opinionated code automatically, and integrates with various databases and APIs, allowing you to focus more on creating your application’s business logic.
Minimum Requirements
🔧 Installation
Open your terminal and run the following command to install:
go install github.com/Ignaciojeria/einar@v1.47.0👨💻 Create a New Project
To start a new project, create an empty folder, open your terminal inside that folder, and run:
einar init my-first-einar-projectThis will create a new project in your current directory with all the necessary files and configurations for your app. Your main method will load all dependencies of your application using einar-ioc dependency injection framework :
//go:embed .versionvar version string
func main() { os.Setenv(constants.Version, version) if err := ioc.LoadDependencies(); err != nil { log.Fatal(err) }}🔧 Install HTTP Server
Inside your project directory, run the following command to install the http server:
einar install fuegoeinar install labstack-echo🌐 Check application status
Inside your project directory, run the following command to start the server:
go run main.goOnce the server starts, execute the following GET Request to retrieve information about the health status of your service:
curl http://localhost:8080/healthInvoke-WebRequest -Uri http://localhost:8080/health -Method GETResponseBody:
{ "status": "OK", "timestamp": "2024-05-06T01:44:26.4251148-04:00", "system": { "version": "go1.22.0", "goroutines_count": 8, "total_alloc_bytes": 1040464, "heap_objects_count": 7102, "alloc_bytes": 1040464 }, "component": { "name": "my-first-einar-project", "version": "1.0.0" }}