您的位置:首页 > 编程语言 > Go语言

Golang学习笔记 (一)

2015-11-08 17:16 615 查看
小记一下go的语法,风格

关于Exported names ,首字母不是大写的都不能作为输出。也不能被导入到另一个包中然后使用。

int型在32位系统上为32位,在64位系统上为64位,和C一样。

Variables declared without an explicit initial value are given their zero value.变量未被赋值时:0 for numeric types,

false the boolean type, and

“” (the empty string) for strings.

import :在同时引入多个包时,可以放在括号中。如

import (
"fmt"
"math"
)


Type conversions:类型转换 The expression T(v) converts the value v to the type T. 类型转换时,必须显式转换,Unlike in C, in Go assignment between items of different type requires an explicit conversion.

Type inference: the variable’s type is inferred from the value on the right hand side.

fmt.Printf() fmt.Printfln()(输出行)

Constants:

Constants are declared like variables, but with the const keyword.

*Constants can be character, string, boolean, or numeric values.*

*Constants cannot be declared using the := syntax.*


-
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  golang go