wireKit

package
v3.0.66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Bind 建立接口类型和具体的实现类型之间的绑定关系,这样 Wire 工具就可以根据这个绑定关系进行类型匹配并生成代码.
	/*
		wire.Bind 的第一个参数是指向所需接口类型值的指针,第二个实参是指向实现该接口的类型值的指针。
	*/
	Bind func(iface, to interface{}) wire.Binding = wire.Bind

	// Struct 根据现有的类型进行构造结构体.
	/*
		使用 wire.Struct 函数需要传递两个参数,第一个参数是结构体类型的指针值,另一个参数是一个可变参数,表示需要注入的结构体字段的名称集。
	*/
	Struct func(structType interface{}, fieldNames ...string) wire.StructProvider = wire.Struct

	// Value
	Value = wire.Value

	// InterfaceValue
	InterfaceValue = wire.InterfaceValue

	// FieldsOf
	FieldsOf = wire.FieldsOf
)
View Source
var (
	// Build 声明一个注入器函数.
	/*
		PS:
		(1) 与提供者一样,注入器也可以输入参数(然后将其发送给提供者),并且可以返回错误.
		(2) wire.Build 的参数和 wire.NewSet 一样:都是提供者集合。这些就在该注入器的代码生成期间使用的提供者集。

		@return 这个函数的返回值也无关紧要,只要它们的类型正确即可,这些值在生成的代码中将被忽略
	*/
	Build func(...interface{}) string = wire.Build
)
View Source
var (
	// NewSet 将多个提供者函数添加到一个集合中.
	/*
		PS:
		(1) 如果经常同时使用多个提供者函数,这非常有用;
		(2) 实践中, 一组业务相关的 provider 时常被放在一起组织成 ProviderSet,以方便维护与切换;
		(3) 可以将其他提供者函数集添加到提供者函数集中.
	*/
	NewSet func(...interface{}) wire.ProviderSet = wire.NewSet
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL