Skip to content

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:

Terminal window
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:

Terminal window
einar init my-first-einar-project

This 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 :

Terminal window
//go:embed .version
var 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:

Terminal window
einar install fuego

🌐 Check application status

Inside your project directory, run the following command to start the server:

Terminal window
go run main.go

Once the server starts, execute the following GET Request to retrieve information about the health status of your service:

Terminal window
curl http://localhost:8080/health

ResponseBody:

Terminal window
{
"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"
}
}