reflect
中,在标准库中定义了两种类型来表现运行时的对象信息,分别是:reflect.Value
(反射对象的类型)和 reflect.Type
(反射对象的值),Go 语言中所有反射操作都是基于这两个类型进行的。reflect
中,在标准库中定义了两种类型来表现运行时的对象信息,分别是:reflect.Value
(反射对象的类型)和 reflect.Type
(反射对象的值),Go 语言中所有反射操作都是基于这两个类型进行的。Most example code taken from A Tour of Go, which is an excellent introduction to Go.
If youre new to Go, do that tour. Seriously.
Imperative language
Statically typed
Syntax tokens similar to C (but less parentheses and no semicolons) and the structure to Oberon-2
Compiles to native code (no JVM)
No classes, but structs with methods
Interfaces
No implementation inheritance. Theres type embedding, though.
Functions are first class citizens
Functions can return multiple values
Has closures
Pointers, but not pointer arithmetic
Built-in concurrency primitives: Goroutines and Channels
最近抽空学习了一下
Go
语言,好多特性感觉非常棒,由于高效的开发效率以及性能,现在好多优秀的开源项目都是基于Go
开发,比如Docker
、etcd
、consul
、Kubernetes
等。Go
势必会在互联网技术的服务化,容器化的将来大展拳脚。正好网上看到一篇关于Java
程序员入门Golang
的文章,写的挺好的,所以特此转载过来,再加上自己的一些学习经验,供大家参考。
Golang
从 09
年发布,中间经历了多个版本的演进,已经渐渐趋于成熟,其媲美于 C
语言的性能、Python
的开发效率,又被称为 21 世纪的 C
语言,尤其适合开发后台服务。这篇文章主要是介绍 Golang
的一些主要特性,和 Java
做一个对比,以便更好的理解 Golang
这门语言。
关于 Golang
环境的搭建就不讲了,可以参考 官方文档 或者大神 astaxie 的开源书籍 build-web-application-with-golang 的相关篇章。下面我没让你就从 Go
版本的 Hello World
开始。