Skip to content

Tsotsi/go_container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

info

inspired by pimple

usage

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
}

About

go container pimple

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages