func (g *Graph) Provide(objects ...*Object) error {
	for _, o := range objects {
		o.reflectType = reflect.TypeOf(o.Value)
		o.reflectValue = reflect.ValueOf(o.Value)

		if o.Fields != nil {
			return fmt.Errorf(
				"fields were specified on object %s when it was provided",
				o,
			)
		}

		if o.Name == "" {
			if !isStructPtr(o.reflectType) {
				return fmt.Errorf(
					"expected unnamed object value to be a pointer to a struct but got type %s "+
						"with value %v",
					o.reflectType,
					o.Value,
				)
			}

			if !o.private {
				if g.unnamedType == nil {
					g.unnamedType = make(map[reflect.Type]bool)
				}

				if g.unnamedType[o.reflectType] {
					return fmt.Errorf(
						"provided two unnamed instances of type *%s.%s",
						o.reflectType.Elem().PkgPath(), o.reflectType.Elem().Name(),
					)
				}
				g.unnamedType[o.reflectType] = true
			}
			g.unnamed = append(g.unnamed, o)
		} else {
			if g.named == nil {
				g.named = make(map[string]*Object)
			}

			if g.named[o.Name] != nil {
				return fmt.Errorf("provided two instances named %s", o.Name)
			}
			g.named[o.Name] = o
		}

		if g.Logger != nil {
			if o.created {
				g.Logger.Debugf("created %s", o)
			} else if o.embedded {
				g.Logger.Debugf("provided embedded %s", o)
			} else {
				g.Logger.Debugf("provided %s", o)
			}
		}
	}
	return nil
}
func (g *Graph) Provide(objects ...*Object) error {
	for _, o := range objects {
		o.reflectType = reflect.TypeOf(o.Value)
		o.reflectValue = reflect.ValueOf(o.Value)

		if o.Fields != nil {
			return fmt.Errorf(
				"fields were specified on object %s when it was provided",
				o,
			)
		}

		if o.Name == "" {
			if !isStructPtr(o.reflectType) {
				return fmt.Errorf(
					"expected unnamed object value to be a pointer to a struct but got type %s "+
						"with value %v",
					o.reflectType,
					o.Value,
				)
			}

			if !o.private {
				if g.unnamedType == nil {
					g.unnamedType = make(map[reflect.Type]bool)
				}

				if g.unnamedType[o.reflectType] {
					return fmt.Errorf(
						"provided two unnamed instances of type *%s.%s",
						o.reflectType.Elem().PkgPath(), o.reflectType.Elem().Name(),
					)
				}
				g.unnamedType[o.reflectType] = true
			}
			g.unnamed = append(g.unnamed, o)
		} else {
			if g.named == nil {
				g.named = make(map[string]*Object)
			}

			if g.named[o.Name] != nil {
				return fmt.Errorf("provided two instances named %s", o.Name)
			}
			g.named[o.Name] = o
		}

		if g.Logger != nil {
			if o.created {
				g.Logger.Debugf("created %s", o)
			} else if o.embedded {
				g.Logger.Debugf("provided embedded %s", o)
			} else {
				g.Logger.Debugf("provided %s", o)
			}
		}
	}
	return nil
}
func ( g * Graph ) Provide ( objects ... * Object ) error { for _ , o := range objects { o . reflectType = reflect . TypeOf ( o . Value ) o . reflectValue = reflect . ValueOf ( o . Value ) if o . Fields != nil { return fmt . Errorf ( " " , o , ) } if o . Name == " " { if ! isStructPtr ( o . reflectType ) { return fmt . Errorf ( " " + " " , o . reflectType , o . Value , ) } if ! o . private { if g . unnamedType == nil { g . unnamedType = make ( map [ reflect . Type ] bool ) } if g . unnamedType [ o . reflectType ] { return fmt . Errorf ( " " , o . reflectType . Elem ( ) . PkgPath ( ) , o . reflectType . Elem ( ) . Name ( ) , ) } g . unnamedType [ o . reflectType ] = true } g . unnamed = append ( g . unnamed , o ) } else { if g . named == nil { g . named = make ( map [ string ] * Object ) } if g . named [ o . Name ] != nil { return fmt . Errorf ( " " , o . Name ) } g . named [ o . Name ] = o } if g . Logger != nil { if o . created { g . Logger . Debugf ( " " , o ) } else if o . embedded { g . Logger . Debugf ( " " , o ) } else { g . Logger . Debugf ( " " , o ) } } } return nil }
// Provide objects to the Graph. The Object documentation describes
// the impact of various fields.
Provide objects to the Graph . The Object documentation describes the impact of various fields .