How do you guys choose between constructors and lazy initialization?

For example.

Struct constructors:

type meow struct {
    x http.Handler
}

func newMeow() *meow {
    return &meow{
        x: http.NewServeMux(),
    }
}

func (m *meow) do() {
    // stuff
}


Lazy initialization:

type meow struct {
    x http.Handler
}

func (m *meow) do() {
    if m.x == nil {
        m.x = http.NewServeMux()
    }
    // stuff
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to