[Golong] Study Notes (1) Basic knowledge

Source: Internet
Author: User
Basic go programming: few built-in keywords (25)

Break default func interface select
Case defer go map struct
Chan else goto package Switch
Const fallthrough if range type
Continute for Import Return VaR

Go annotation method (same as JS)

Single line comment ://
Multi-line comment :/**/

The general structure of the Go program is common_structure.go.
  • PassPackageOrganize code structures (similar to Python modules)
  • OnlyPackageName:MainThe package can containMainFunction
  • One executable program has only oneMainPackage
  • PassImportTo import packages
  • ConstUsed to define constants (similar to C)
  • External Use of function bodyVaRTo declare and assign values to global variables.
  • Complex typesStruct,InterfaceTo useTypeKeyword to declare
  • FuncTo declare a function

Simple demo

/*title: common_structure.goauthor: orangleliudate: 2014-08-05des: the simple demo of erlang*/// a package only have a mainpackage main// use “import” import other packagesimport “fmt”const Lzz = “Orangleliu”var name = “erlong”type age inttype golang struct{}func main(){    fmt.Println(“I love Erlog!”)}

1. How to import multiple packages

import (    “fmt”    “os”    “time”)

2. use aliases

import (    std “fmt”)
Naming Conventions

Case SensitiveConstant, variable, type, interface, structure or functionPublic or private

For example:
1. The first letter of the function name is lowercase: Private
2. function names are capitalized: Public

Learning material address

This article is from the "orangleliu notebook" blog, please be sure to keep this http://blog.csdn.net/orangleliu/article/details/38393085

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.