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