Simple service container written in Go.
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
vertebrae.go

README.md

Vertebrae

Simple DI container, written in Go

Link to the pair blog post

// Example:
myApp := &MyApp{}
container := new(Vertebrae)

container.Add("my.service", myApp)
container.Add("my.string", "Testing 123")

myService, ok := container.Get("my.service")

if !ok {
    panic("Service 'my.service' not found!")    
}

myString, ok := container.Get("my.string")

if !ok {
    panic("Service 'my.string' not found!")    
}

fmt.Println(myService.(*MyApp).TestService(23))
fmt.Println(myString.(string))

type MyApp struct{}

func (myApp *MyApp) TestService(param int) int {
	return 12 + param
}