Summer是一个Golang的简单的IOC框架。
实现了基本的依赖注入,配置文件属性注入等。
易扩展,简单。
简单的示例代码如下:
package main import ( "github.com/cocotyty/summer" "fmt" ) func init() { summer.Toml(` [printer] prefix="[PRINT]"`) summer.Put(&A{}) summer.Add("lay", &B{}) summer.Put(&Cat{}) summer.Put(&Printer{}) summer.Start() } func main() { a := summer.GetStoneWithName("a").(*A) a.Call() } type A struct { // $ means you want to get a stone's field , it happened usually after stones inited BoyName string `sm:"$.lay.Name"` B *B `sm:"lay"` // yes,we support interface ,tag is stone's name C C `sm:"cat"` } func (a *A)Call() { a.C.Print() fmt.Println("hi ,I am A", "bodys name:", a.BoyName) fmt.Println(a.B) } type B struct { Name string } func (this *B)Init() { this.Name = "Boy!" } type C interface { Print() } type Printer struct { // if you already set the toml plugin config, you can use the # ,to get value from toml, // # is toml plugin's name // toml plugin will work after directly dependency resolved,before init Prefix string `sm:"#.printer.prefix"` } func (printer *Printer)Print(str string) { fmt.Println(printer.Prefix + str) } type Cat struct { // * is mostly used tag,summer will find by the field's name or the field's type or both Printer *Printer `sm:"*"` } func (c *Cat)Ready() { fmt.Println("my name is cat,i am ready.") } func (c *Cat)Print() { c.Printer.Print("Little Cat") }
D. Time to go back time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have been out of Syria for a long time, and you recently decided to
In this hot summer AIUB students decided to go on a trip to Cox’s Bazaar sea beach. Every student has some amount of money to spend in this trip. Each student belongs to some group. If student A knows
Summer Reading time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output At school Vasya got an impressive list of summer reading books. Unlike other
SHIRLEY GRIFFITH: I'm Shirley Griffith. [color=blue]SHIRLEY GRIFFITH:我是Shirley Griffith.[/color] STEVE EMBER: And I'm Steve Ember with EXPLORATIONS in VOA Special English. Our subject today is books.
IAPCR2F - Summer Trip no tags In this hot summer AIUB students decided to go on a trip to Cox’s Bazaar sea beach. Every student has some amount of money to spend in this trip. Each student belongs to
嵐-IN THE SUMMER FLAC 07/29 IN THE SUMMER - 嵐 (あらし) 词:Rami Yacoub/Gregory Hein/Funk Uchino 曲:Rami Yacoub 编曲:Rami Yacoub Feet in the sand Cancel your plans We only got one life Let\'s live it while we c
Go语言从入门到规范-6.3、Go语言IO操作-io相关包和bufio 1. 前言 Go的IO通过我们之前学习总结的Go常用包可以看出来基本有io、ioutil、bufio三个,bufio是我们在业务层面开发时需要学习了解的重点,本文的重点也是bufio,对于io和ioutil有相关性,所以简单带过,目前不做专门总结,感兴趣的小伙伴可以自行学习。(关于I/O这里就不多说了,简单理解就是数据的输入/
04E:Project Summer 总时间限制: 1000ms 内存限制: 65536kB 描述 小 I 和小 B 最近沉迷一款叫做《Project Summer》的游戏,小 I 扮演这个游戏中需要逃生的无辜者(Innocent), 小 B 扮演这个游戏中抓住无辜者,阻止其逃生的背叛者(Betrayer)。 这个游戏的地图是一个 N 行 M 列 的矩形,每个格点表示一个位置。
J - Intelligent IME 时限:1000MS 内存:32768KB 64位IO格式:%I64d & %I64u 问题描述 We all use cell phone today. And we must be familiar with the intelligent English input method on the cell phone. To be sp
——————水赛总结 A - Window Gym - 101020A Jerry Smith is Rick's Son-in-Law and Morty's father. He recently moved out to a different neighborhood. Unfortunately Jerry is not very Smart or Bright. The new n
数组 package array import "testing" func TestArrayInit(t *testing.T){ var arr = [...]int{1,2,3} arr1 := [3]int{1,2} for i:=0;i<3;i++{ t.Log(arr[i]) } t.Log(arr1[1:]) } func TestArrayLoop(t *te
Go-IOC 是一款为 Go 语言开发的运行时依赖注入库。Go 语言的语言特性决定了实现一款类型安全的依赖注入容器并不太容易,因此 Go-IOC 大量使用了 Go 的反射机制。如果你的使用场景对性能要求并不是那个苛刻,那 Go-IOC 非常适合你。 并不是说对性能要求苛刻的环境中就不能使用了,你可以把 Go-IOC 作为一个对象依赖管理工具,在你的业务初始化时获取依赖的对象。 使用方式 go ge
问题内容: 谁能指出我一个简单的Java开源Map / Reduce框架/ API?似乎没有太多证据表明存在这种事物,但是其他人可能知道不同。 我所能找到的最好的当然是HadoopMapReduce,但这不符合“简单”标准。我不需要运行分布式作业的能力,仅需要让我使用标准Java5风格的并发性在单个JVM中的多核计算机上运行映射/简化样式的作业。 写自己不是一件难事,但我宁愿不必这样做。 问题
实现一个最最简单的数学计算:加、减、乘、除,给大家演示如何搭建简单的 API Server。按照前面几章的写法,先来看看加法、减法示例代码: worker_processes 1; #nginx worker 数量 error_log logs/error.log; #指定错误日志文件路径 events { worker_connections 1024; } http
主要内容:Go语言工程结构简单,Go语言编译速度快Go语言语法简单易懂,学习曲线平缓,不需要像 C/ C++ 语言动辄需要两到三年的学习期。Go语言被称为“互联网时代的C语言”。互联网的短、频、快特性在Go语言中体现得淋漓尽致。一个熟练的开发者只需要短短的一周时间就可以从学习阶段转到开发阶段,并完成一个高并发的服务器开发。 Go语言是 Google 公司开发的一种静态型、编译型并自带垃圾回收和并发的编程语言。所以它是一门类型安全的语言,加上通过构
本文向大家介绍简单解析Django框架中的表单验证,包括了简单解析Django框架中的表单验证的使用技巧和注意事项,需要的朋友参考一下 我们的搜索示例仍然相当地简单,特别从数据验证方面来讲;我们仅仅只验证搜索关键值是否为空。 然后许多HTML表单包含着比检测值是否为空更为复杂的验证。 我们都有在网站上见过类似以下的错误提示信息: 请输入一个有效的email地址, foo' 并不是一个有效的
本文向大家介绍jQuery下拉框的简单应用,包括了jQuery下拉框的简单应用的使用技巧和注意事项,需要的朋友参考一下 先看看效果图: 大家肯定都见过类似效果的网页,怎么实现的呢,代码很简单: 代码实现的功能: 1)、将选中的选项添加给对方 2)、将全部选项添加给对方 3)、双击某个选项将其添加给对方 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持呐喊教程。
问题内容: 我指的是“ 有效Java ”的第2章中讨论的“服务提供者框架” ,这似乎是解决我遇到的问题的正确方法,其中我需要在运行时实例化几个类之一,并根据选择一个服务和一个对象(基本上是XML代码段): 但是,如何让各个服务提供者(例如,一堆默认提供者+一些自定义提供者)进行注册? 例如,如果我编写了自定义类MyFooAlgorithm和MyFooAlgorithmProvider来实现FooA
本文向大家介绍写简单的mvc框架实例讲解,包括了写简单的mvc框架实例讲解的使用技巧和注意事项,需要的朋友参考一下 这一章先把支持注解的功能加上,这样就不需要经常地修改配置文件了。 至于视图处理的地方,就还是先用json吧,找时间再写。 项目地址在:https://github.com/hjx601496320/aMvc 。 测试代码在:https://github.com/hjx60149632