一句话总结:解耦组件之间的依赖关系,避免手动配置每个组件的依赖关系。



package main

import (
   "fmt"
   "net/http"
   "os"

   "github.com/facebookgo/inject"
)

// Our Awesome Application renders a message using two APIs in our fake
// world.
type HomePlanetRenderApp struct {
   // The tags below indicate to the inject library that these fields are
   // eligible for injection. They do not specify any options, and will
   // result in a singleton instance cre