go语言
jaykiller123
这个作者很懒,什么都没留下…
展开
-
Go语言入门(一)——接口的实现
package mainimport ( "fmt")/*接口*/type IFly interface { Fly()}/*Bird结构体*/type Bird struct {}/*接口方法的实现*/func (b *Bird) Fly() { fmt.Println("Bird can fly")}/*Duck结构体*/type Duck struct原创 2016-01-23 10:30:23 · 520 阅读 · 0 评论 -
Go语言入门(二)——第一个Go程序
package main //包声明/* 第一个Go程序 */import ( //导入fmt库 "fmt")/* Go可执行程序的执行起点,main函数不能带参数,也不能定义返回值 */func main() { fmt.Println("Hello Go!") //在控制台打印Hello Go!}原创 2016-01-23 10:58:56 · 321 阅读 · 0 评论 -
Go语言入门(三)——map
map是一堆键值对的未排序集合,可对map进行创建,修改值,删除键,根据键查找等功能。package mainimport ( "fmt")/* * 用户实体 */type User struct { id string username string password string manager bool}func main()原创 2016-01-23 14:54:29 · 340 阅读 · 0 评论 -
Go语言入门(四)——不定参数
不定参数类型不定参数是指函数传入的参数个数为不定数量。package mainimport ( "fmt")/*不定参数函数*/func Add(a int, args ...int) (result int) { result += a for _, arg := range args { result += arg } return原创 2016-01-23 15:38:36 · 3939 阅读 · 0 评论