All Projects â†’ goava â†’ di

goava / di

Licence: MIT license
🛠 A full-featured dependency injection container for go programming language.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to di

Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-59.62%)
Mutual labels:  ioc, dependency-injection, ioc-container, di
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-85.9%)
Mutual labels:  ioc, dependency-injection, ioc-container, di
Reflex
Minimal dependency injection framework for Unity
Stars: ✭ 263 (+68.59%)
Mutual labels:  ioc, dependency-injection, ioc-container, di
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+1637.82%)
Mutual labels:  ioc, dependency-injection, ioc-container, di
inject
[Archived] See https://github.com/goava/di.
Stars: ✭ 49 (-68.59%)
Mutual labels:  ioc, dependency-injection, ioc-container, di
ashley
Ashley is a dependency injection container for JavaScript.
Stars: ✭ 23 (-85.26%)
Mutual labels:  ioc, dependency-injection, ioc-container
Disco
PSR-11 compatible Dependency Injection Container for PHP.
Stars: ✭ 135 (-13.46%)
Mutual labels:  ioc, dependency-injection, ioc-container
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (-76.92%)
Mutual labels:  ioc, dependency-injection, ioc-container
Container
A lightweight yet powerful IoC container for Go projects
Stars: ✭ 160 (+2.56%)
Mutual labels:  ioc, dependency-injection, ioc-container
Hiboot
hiboot is a high performance web and cli application framework with dependency injection support
Stars: ✭ 150 (-3.85%)
Mutual labels:  ioc, dependency-injection, di
waiter
Dependency injection, Inversion of control container for rust with compile time binding.
Stars: ✭ 71 (-54.49%)
Mutual labels:  ioc, dependency-injection, di
React Ioc
Hierarchical Dependency Injection with new React 16 Context API
Stars: ✭ 133 (-14.74%)
Mutual labels:  ioc, dependency-injection, ioc-container
Container Ioc
Inversion of Control container & Dependency Injection for Javascript and Node.js apps powered by Typescript.
Stars: ✭ 89 (-42.95%)
Mutual labels:  ioc, dependency-injection, di
Node Dependency Injection
The NodeDependencyInjection component allows you to standarize and centralize the way objects are constructed in your application.
Stars: ✭ 140 (-10.26%)
Mutual labels:  ioc, dependency-injection, ioc-container
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+671.15%)
Mutual labels:  ioc, dependency-injection, ioc-container
DI-compiler
A Custom Transformer for Typescript that enables compile-time Dependency Injection
Stars: ✭ 62 (-60.26%)
Mutual labels:  ioc, dependency-injection, di
SwiftInjection
Dependency Injection framework for Swift
Stars: ✭ 21 (-86.54%)
Mutual labels:  ioc, dependency-injection, ioc-container
Di
Dependency Injection and IoC framework for PHP
Stars: ✭ 5 (-96.79%)
Mutual labels:  ioc, dependency-injection, ioc-container
Poodinis
A dependency injection framework for D with support for autowiring.
Stars: ✭ 57 (-63.46%)
Mutual labels:  ioc, dependency-injection, ioc-container
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (+9.62%)
Mutual labels:  ioc, dependency-injection, ioc-container

DI

Documentation Release Build Status Go Report Card Code Coverage

Dependency injection for Go programming language.

Tutorial | Examples | Advanced features

Dependency injection is one form of the broader technique of inversion of control. It is used to increase modularity of the program and make it extensible.

This library helps you to organize responsibilities in your codebase and make it easy to combine low-level implementation into high-level behavior without boilerplate.

Features

  • Intuitive auto wiring
  • Interface implementations
  • Constructor injection
  • Optional injection
  • Field injection
  • Lazy-loading
  • Tagging
  • Grouping
  • Cleanup
  • Container Chaining / Scopes

Documentation

You can use standard pkg.go.dev and inline code comments. If you do not have experience with auto-wiring libraries as google/wire, uber-go/dig or another - start with tutorial.

Install

go get github.com/goava/di

What it looks like

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"os"
	"os/signal"
	"syscall"

	"github.com/goava/di"
)

func main() {
	di.SetTracer(&di.StdTracer{})
	// create container
	c, err := di.New(
		di.Provide(NewContext),  // provide application context
		di.Provide(NewServer),   // provide http server
		di.Provide(NewServeMux), // provide http serve mux
		// controllers as []Controller group
		di.Provide(NewOrderController, di.As(new(Controller))),
		di.Provide(NewUserController, di.As(new(Controller))),
	)
	// handle container errors
	if err != nil {
		log.Fatal(err)
	}
	// invoke function
	if err := c.Invoke(StartServer); err != nil {
		log.Fatal(err)
	}
}

Full code available here.

Questions

If you have any questions, feel free to create an issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].