Go language 1 hours--never to get started

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.