https://github.com/tsotsi/go_container
go container pimple
https://github.com/tsotsi/go_container
go golang pimple
Last synced: 4 months ago
JSON representation
go container pimple
- Host: GitHub
- URL: https://github.com/tsotsi/go_container
- Owner: Tsotsi
- Created: 2018-01-03T15:09:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-29T16:05:01.000Z (almost 7 years ago)
- Last Synced: 2024-12-30T04:25:52.078Z (6 months ago)
- Topics: go, golang, pimple
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## info
> inspired by pimple## usage
```golang
type Abc struct{
Cc int
}c := NewContainer()
c.Set("test", func(cc *Container){
a := new(Abc)
a.Cc = 1988
return a
})if f,ok:=c.Get("test");ok{
println(f.(*Abc).Cc == 1988) // true
f.(*Abc).Cc += 10
}if f,ok:=c.Get("test");ok{
println(f.(*Abc).Cc == 1998) // true
}c1 := NewContainer()
c1.Factory("test", func(cc *Container){
a := new(Abc)
a.Cc = 1988
return a
})if f,ok:=c1.Get("test");ok{
println(f.(*Abc).Cc == 1988) // true
f.(*Abc).Cc += 10
}if f,ok:=c1.Get("test");ok{
println(f.(*Abc).Cc == 1988) // true
}```