go语言系列基础教程总结(1):

1、引入包

import  "fmt" 

import   "time"

2、变量声明

var a int = 100

3、常量声明

const a int = 10

4、方法声明

func  test(a string,b int){

        fmt.Println("a=", a)

}

5、方法返回多个返回值

func test2(a int) (r1 int, r2 int){

        return 

}

6、import 导包

_ 代表匿名 . 代表导入全部方法。import  test  "fmt"  test代表别名,可以通过别名调用方法

7、deffer关键字

deffer相当于java中的finally。在方法中的最后执行,(return之后)

猜你喜欢

转载自blog.csdn.net/u013558123/article/details/131394458