Golang basic knowledge of learning notes

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

1.Go built-in keywords and annotation methods

break      default       func     interface   selectcase       defer         go       map         structchan       else          goto     package     switchconst      fallthrough   if       range       typecontinue   for           import   return      var

General structure of the 2.GO program

//当前程序的包名package main//导入其它的包import "fmt"//全部变量的声明与赋值var name = "gopher"//一般类型的声明type newType int//结构的声明type gopher struct{}//接口的声明type golang interface{}//由main函数作为程序入口点启动func main() {    fmt.Println("Hello World!")}

3. Import of Packages

  • Package aliases and Ellipsis calls
别名:import std "fmt"省略调用(这样可以不用写包名,直接调用):import . "fmt" 初始化,但不调用:import _ "github.com/go-sql-driver/mysql"
  • Visibility rules
只有首字母为大写的才能被其它包调用(类似面向对象里面的属性public 和private)

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.