Ax--go Language Learning Essential Information:
1. Go download and install
2. Official document effective Go
3. Official documents Chinese translation PDF download
4. Chinese-written go ide--liteide 32.1
This text address: http://blog.csdn.net/caib1109/article/details/75578974
The first step--hello world
Testdemo Project Main.go Package
main
import (
"FMT"
)
func main () {
fmt. Println ("Hello world!")
}
The second step--project structure
Go install and go build contention. The idea plugin and liteide are now using go build. The Eclipse plugin uses go install. Official recommended go install way to compile the project, the official project structure should be
Project name
|--bi
|--pkg
+--src
Step three--package Main, func main () {}, func init () {}
A picture wins thousands of words
Fourth Step--go Language object-oriented
File Name:main.go Package
main
import (
"FMT"
)
type Human interface {talk
()
}
Type person struct {
name string
Human//person is-a Human
}
func (P *person) talk () {
fmt. Println ("Hi, my Name is", P.name)
}
type citizen struct {
country string
person person Human //b is-a a
}
func (c *citizen) talk () {
fmt. Println ("Hi, my Name is", C.person.name)
}
func speakto (H Human) {
h.talk ()
}
func main () { C29/>p: = person{name: "Dave"}
C: = citizen{person:person{name: "Steve"}, Country: "America"}
Speakto (&p )
Speakto (&c)
}
Fifth Step--go language concurrency
File Name:main.go Package
main
import (
"FMT"
)
var ch = make (Chan string)
func Message () {
msg: = <-ch
fmt. PRINTLN (msg)
}
func main () {
go message ()
ch <-"HELLO,CSP."
}
Expand reading:
[1] The object-oriented, interface, Pseudo-polymorphic, and true polymorphism of the Go language