Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: '1.22'
stable: false
- uses: actions/checkout@v2
- name: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: '1.22'
stable: false

- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: '1.22'
stable: false

- name: Build
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

BIN=go
# BIN=go1.18beta1
# BIN=go1.22

go1.18beta1:
go install golang.org/dl/go1.18beta1@latest
go1.18beta1 download
go1.22:
go install golang.org/dl/go1.22@latest
go1.22 download

build:
${BIN} build -v ./...
Expand Down
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
> This is a forked of the original [Do](https://github.com/samber/do) package with an extension to allow dynamically injecting depdencies to a struct through reflection.


![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.18-%23007d9c)
[![GoDoc](https://godoc.org/github.com/cryptoniumX/di?status.svg)](https://pkg.go.dev/github.com/cryptoniumX/di)
![Build Status](https://github.com/cryptoniumX/di/actions/workflows/test.yml/badge.svg)
[![Go report](https://goreportcard.com/badge/github.com/cryptoniumX/di)](https://goreportcard.com/report/github.com/cryptoniumX/di)
![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.22-%23007d9c)
[![GoDoc](https://godoc.org/github.com/fystack/di?status.svg)](https://pkg.go.dev/github.com/fystack/di)
![Build Status](https://github.com/fystack/di/actions/workflows/test.yml/badge.svg)
[![Go report](https://goreportcard.com/badge/github.com/fystack/di)](https://goreportcard.com/report/github.com/fystack/di)
[![Coverage](https://img.shields.io/codecov/c/github/samber/do)](https://codecov.io/gh/samber/do)
[![License](https://img.shields.io/github/license/samber/do)](./LICENSE)

**⚙️ A dependency injection toolkit based on Go 1.18+ Generics.**
**⚙️ A dependency injection toolkit based on Go 1.22+ Generics.**

This library implements the Dependency Injection design pattern. It may replace the `uber/dig` fantastic package in simple Go projects. `samber/do` uses Go 1.18+ generics and therefore is typesafe.
This library implements the Dependency Injection design pattern. It may replace the `uber/dig` fantastic package in simple Go projects. `samber/do` uses Go 1.22+ generics and therefore is typesafe.

## 💡 Features

Expand Down Expand Up @@ -66,7 +66,7 @@ func newService(
## 🚀 Install

```sh
go get github.com/cryptoniumX/di@v1
go get github.com/fystack/di@v1
```

This library is v1 and follows SemVer strictly.
Expand All @@ -81,7 +81,7 @@ You can import `do` using:

```go
import (
"github.com/cryptoniumX/di"
"github.com/fystack/di"
)
```

Expand Down Expand Up @@ -151,47 +151,47 @@ func (c *CarService) Shutdown() error {

## 🤠 Spec

[GoDoc: https://godoc.org/github.com/cryptoniumX/di](https://godoc.org/github.com/cryptoniumX/di)
[GoDoc: https://godoc.org/github.com/fystack/di](https://godoc.org/github.com/fystack/di)

Container:

- [di.New](https://pkg.go.dev/github.com/cryptoniumX/di#New)
- [di.NewWithOpts](https://pkg.go.dev/github.com/cryptoniumX/di#NewWithOpts)
- [Container.Clone](https://pkg.go.dev/github.com/cryptoniumX/di#Container.Clone)
- [Container.CloneWithOpts](https://pkg.go.dev/github.com/cryptoniumX/di#Container.CloneWithOpts)
- [Container.HealthCheck](https://pkg.go.dev/github.com/cryptoniumX/di#Container.HealthCheck)
- [Container.Shutdown](https://pkg.go.dev/github.com/cryptoniumX/di#Container.Shutdown)
- [Container.ShutdownOnSIGTERM](https://pkg.go.dev/github.com/cryptoniumX/di#Container.ShutdownOnSIGTERM)
- [Container.ShutdownOnSignals](https://pkg.go.dev/github.com/cryptoniumX/di#Container.ShutdownOnSignals)
- [Container.ListProvidedServices](https://pkg.go.dev/github.com/cryptoniumX/di#Container.ListProvidedServices)
- [Container.ListInvokedServices](https://pkg.go.dev/github.com/cryptoniumX/di#Container.ListInvokedServices)
- [di.HealthCheck](https://pkg.go.dev/github.com/cryptoniumX/di#HealthCheck)
- [di.HealthCheckNamed](https://pkg.go.dev/github.com/cryptoniumX/di#HealthCheckNamed)
- [di.Shutdown](https://pkg.go.dev/github.com/cryptoniumX/di#Shutdown)
- [di.ShutdownNamed](https://pkg.go.dev/github.com/cryptoniumX/di#ShutdownNamed)
- [di.MustShutdown](https://pkg.go.dev/github.com/cryptoniumX/di#MustShutdown)
- [di.MustShutdownNamed](https://pkg.go.dev/github.com/cryptoniumX/di#MustShutdownNamed)
- [di.New](https://pkg.go.dev/github.com/fystack/di#New)
- [di.NewWithOpts](https://pkg.go.dev/github.com/fystack/di#NewWithOpts)
- [Container.Clone](https://pkg.go.dev/github.com/fystack/di#Container.Clone)
- [Container.CloneWithOpts](https://pkg.go.dev/github.com/fystack/di#Container.CloneWithOpts)
- [Container.HealthCheck](https://pkg.go.dev/github.com/fystack/di#Container.HealthCheck)
- [Container.Shutdown](https://pkg.go.dev/github.com/fystack/di#Container.Shutdown)
- [Container.ShutdownOnSIGTERM](https://pkg.go.dev/github.com/fystack/di#Container.ShutdownOnSIGTERM)
- [Container.ShutdownOnSignals](https://pkg.go.dev/github.com/fystack/di#Container.ShutdownOnSignals)
- [Container.ListProvidedServices](https://pkg.go.dev/github.com/fystack/di#Container.ListProvidedServices)
- [Container.ListInvokedServices](https://pkg.go.dev/github.com/fystack/di#Container.ListInvokedServices)
- [di.HealthCheck](https://pkg.go.dev/github.com/fystack/di#HealthCheck)
- [di.HealthCheckNamed](https://pkg.go.dev/github.com/fystack/di#HealthCheckNamed)
- [di.Shutdown](https://pkg.go.dev/github.com/fystack/di#Shutdown)
- [di.ShutdownNamed](https://pkg.go.dev/github.com/fystack/di#ShutdownNamed)
- [di.MustShutdown](https://pkg.go.dev/github.com/fystack/di#MustShutdown)
- [di.MustShutdownNamed](https://pkg.go.dev/github.com/fystack/di#MustShutdownNamed)

Service registration:

- [di.Provide](https://pkg.go.dev/github.com/cryptoniumX/di#Provide)
- [di.ProvideNamed](https://pkg.go.dev/github.com/cryptoniumX/di#ProvideNamed)
- [di.ProvideNamedValue](https://pkg.go.dev/github.com/cryptoniumX/di#ProvideNamedValue)
- [di.ProvideValue](https://pkg.go.dev/github.com/cryptoniumX/di#ProvideValue)
- [di.Provide](https://pkg.go.dev/github.com/fystack/di#Provide)
- [di.ProvideNamed](https://pkg.go.dev/github.com/fystack/di#ProvideNamed)
- [di.ProvideNamedValue](https://pkg.go.dev/github.com/fystack/di#ProvideNamedValue)
- [di.ProvideValue](https://pkg.go.dev/github.com/fystack/di#ProvideValue)

Service invocation:

- [di.Invoke](https://pkg.go.dev/github.com/cryptoniumX/di#Invoke)
- [di.MustInvoke](https://pkg.go.dev/github.com/cryptoniumX/di#MustInvoke)
- [di.InvokeNamed](https://pkg.go.dev/github.com/cryptoniumX/di#InvokeNamed)
- [di.MustInvokeNamed](https://pkg.go.dev/github.com/cryptoniumX/di#MustInvokeNamed)
- [di.Invoke](https://pkg.go.dev/github.com/fystack/di#Invoke)
- [di.MustInvoke](https://pkg.go.dev/github.com/fystack/di#MustInvoke)
- [di.InvokeNamed](https://pkg.go.dev/github.com/fystack/di#InvokeNamed)
- [di.MustInvokeNamed](https://pkg.go.dev/github.com/fystack/di#MustInvokeNamed)

Service override:

- [di.Override](https://pkg.go.dev/github.com/cryptoniumX/di#Override)
- [di.OverrideNamed](https://pkg.go.dev/github.com/cryptoniumX/di#OverrideNamed)
- [di.OverrideNamedValue](https://pkg.go.dev/github.com/cryptoniumX/di#OverrideNamedValue)
- [di.OverrideValue](https://pkg.go.dev/github.com/cryptoniumX/di#OverrideValue)
- [di.Override](https://pkg.go.dev/github.com/fystack/di#Override)
- [di.OverrideNamed](https://pkg.go.dev/github.com/fystack/di#OverrideNamed)
- [di.OverrideNamedValue](https://pkg.go.dev/github.com/fystack/di#OverrideNamedValue)
- [di.OverrideValue](https://pkg.go.dev/github.com/fystack/di#OverrideValue)

### Container (DI container)

Expand Down Expand Up @@ -499,8 +499,8 @@ func TestService(t *testing.T) {
## 🤝 Contributing

- Ping me on twitter [@samuelberthe](https://twitter.com/samuelberthe) (DMs, mentions, whatever :))
- Fork the [project](https://github.com/cryptoniumX/di)
- Fix [open issues](https://github.com/cryptoniumX/di/issues) or request new features
- Fork the [project](https://github.com/fystack/di)
- Fix [open issues](https://github.com/fystack/di/issues) or request new features

Don't hesitate ;)

Expand Down
2 changes: 1 addition & 1 deletion examples/healthcheckable/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/cryptoniumX/di"
"github.com/fystack/di"
)

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/interface/car.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/cryptoniumX/di"
import "github.com/fystack/di"

type Car interface {
Start()
Expand Down
2 changes: 1 addition & 1 deletion examples/interface/engine.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/cryptoniumX/di"
import "github.com/fystack/di"

type Engine interface{}

Expand Down
2 changes: 1 addition & 1 deletion examples/interface/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/cryptoniumX/di"
"github.com/fystack/di"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/shutdownable/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"log"

"github.com/cryptoniumX/di"
"github.com/fystack/di"
)

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/example.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/cryptoniumX/di"
import "github.com/fystack/di"

/**
* Wheel
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cryptoniumX/di
module github.com/fystack/di

go 1.18
go 1.22

//
// Dependencies are excluded from releases. Please check CI.
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/cryptoniumX/di v1.6.0 h1:Jy/N++BXINDB6lAx5wBlbpHlUdl0FKpLWgGEV9YWqaU=
github.com/cryptoniumX/di v1.6.0/go.mod h1:DWqBvumy8dyb2vEnYZE7D7zaVEB64J45B0NjTlY/M4k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand All @@ -20,6 +19,7 @@ go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading