20170223--go Language Introduction

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Run the binary go file

Installation steps for Golang

Compiling Windows programs under Linux

package mainfunc main(){                //mian为特殊函数,所以不传参和返回  println("hello,go!")}func abc(参数)(返回值-如果有){   //每行会自动加上;    函数体}

Implement syntax highlighting in vim

Go language formatting

Definition of the Help document:

package mainvar abc string  = "uplooking" //全局变量func main(){                //mian为特殊函数,所以不传参和返回    abc = "xyz"    println("hello,go!", abc)    var xyz int      //函数内部变量赋值时也可以不指定变量类型 var xyz = 123    xyz = 123               //函数内部定义的变量只能在函数内部使用    println("xyz:", xyz)    aa := "xyz aa"       // := 也是定义 ,aa已经定义过,不能在进行定义    println("aa:", aa)   // 字符串需要双引号,单引号有其他用途    println("hello"+"world")  //字符串的连接}

Compiling go

Put the go file into a go package

Go build//compile all the files we have wrapped into a package with only one package per directory

Go build will be built in the current directory and go install will be installed under Gobin

Import the package, the first uppercase variable is the exported parameter, can be used outside the package, small-letter variables can only be used inside the package.

Golang find the relative path of the package, cannot give absolute path

View Help documentation

How to read in a row

Nil equivalent to NULL in Python

string conversion to Integer:%T type,%v

Integer conversion to string: No errors, so no error output

-Ignore errors.

For loop, only for no while

Array of slice types

Create a struct (similar to a method of a class)

Parameters of the program

Flag--the equivalent of Python

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.