可以将 ArrayList想象成一种“会自动扩增容量的Array”
在服务器站点执行 git pull
时,报错:
Your local changes to the following files would be overwritten by merge error: Your local changes to the following files would be overwritten by merge: protected/config/main.php Please, commit your changes or stash them before you can merge.
上一篇文章 说到了 Golang 中的反射的一些基本规则,重点就是文章中最后的三点,但是这篇文章并没有说如何在反射中调用函数和方法,这就是接下来要说的。
反射中调用 函数
众所周知,Golang 中的函数是可以像普通的 int、float 等类型变量那样作为值的,例如:
package main import "fmt" func hello() { fmt.Println("Hello world!") } func main() { hl := hello hl() }
prints:
hello world!
既然函数可以像普通的类型变量一样可以的话,那么在反射机制中就和不同的变量是一样的,在反射中 函数 和 方法 的类型(Type)都是 reflect.Func,如果要调用函数的话,可以通过 Value 的 Call() 方法,例如:
func main() { hl := hello fv := reflect.ValueOf(hl) fmt.Println("fv is reflect.Func ?", fv.Kind() == reflect.Func) fv.Call(nil) }
prints:
fv is reflect.Func? true hello world!
Value 的 Call() 方法的参数是一个 Value 的 slice,对应的反射函数类型的参数,返回值也是一个 Value 的 slice,同样对应反射函数类型的返回值。通过这个例子,相信你一看就明白了:
func prints(i int) string { fmt.Println("i =", i) return strconv.Itoa(i) } func main() { fv := reflect.ValueOf(prints) params := make([]reflect.Value, 1) // 参数 params[0] = reflect.ValueOf(20) // 参数设置为20 rs := fv.Call(params) // rs作为结果接受函数的返回值 fmt.Println("result:", rs[0].Interface().(string)) // 当然也可以直接是 rs[0].Interface() }
prints:
i = 20 result: 20
Mac 下,不要升级 Jetbrains 系列产品到 2017.3,工具栏是乱的,bug 比较多
int accept(int s, struct sockaddr *addr, int *addrlen);
accept()用来接受参数s 的socket 连线。参数s 的socket 必需先经bind()、listen()函数处理过,当有连线进来时accept()会返回一个新的socket 处理代码,往后的数据传送与读取就是经由新的socket处理,而原来参数s 的socket 能继续使用accept()来接受新的连线要求。
如果不想用 Maven 自动 管理/下载 Spring,可到官网直接下载离线包(不过里面的版本比较旧)
下载地址:https://repo.spring.io/release/org/springframework/spring/
使用 jQuery 修改 css 中带有 !important 的样式属性
外部样式为:
div.test { width:auto !important; overflow:auto !important }
通过 $("div.test").css("width","100px"); 和 $("div.test").css("width","100px !important"); 是无效的
在 [mysqld] 节点下,增加如下内容:
general_log = ON general_log_file = D:/Data/log/sql.log
general_log = ON 表示开启日志记录,
general_log_file 为日志保存的路径。