技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

随笔分类 -  Go

Go会是我未来10年的安身立命之本吗
GO语言中的指针
摘要:http://www.tizgrape.com/?p=100Go语言中的指针语法和C++一脉相承,都是用*作为符号,虽然语法上接近,但是实际差异不小。Go使用var定义变量:var v6 *int // int* v6; (but no pointer arithmetic)x = *p(*in... 阅读全文

posted @ 2014-06-05 17:49 codestyle 阅读(4255) 评论(1) 推荐(0) 编辑

go 语言与循环
摘要:package mainimport "fmt"type Employee struct{name string; age int} func displayName(e *Employee){ fmt.Printf("employee name is %s , age is %d\n",(*... 阅读全文

posted @ 2014-06-04 16:54 codestyle 阅读(300) 评论(0) 推荐(0) 编辑

GO:格式化代码
摘要:http://www.ituring.com.cn/article/39380Go 开发团队不想要 Go 语言像许多其它语言那样总是在为代码风格而引发无休止的争论,浪费大量宝贵的开发时间,因此他们制作了一个工具:go fmt(gofmt)。这个工具可以将你的源代码格式化成符合官方统一标准的风格,属于语法风格层面上的小型重构。遵循统一的代码风格是 Go 开发中无可撼动的铁律,因此你必须在编译或提交版本管理系统之前使用gofmt来格式化你的代码。尽管这种做法也存在一些争论,但使用gofmt后你不再需要自成一套代码风格而是和所有人使用相同的规则。这不仅增强了代码的可读性,而且在接手外部 Go 项目时 阅读全文

posted @ 2014-02-14 13:43 codestyle 阅读(4193) 评论(0) 推荐(0) 编辑

在 Windows 下部署 Go 语言环境
摘要:http://bbs.chinaunix.net/thread-4088281-1-1.html1. 首先下载官方二进制安装包:32 位选择 windows-386.msi64 位选择 windows-386.msihttp://code.google.com/p/go/down ... ws+Type%3DInstallercmd输入:go version如果有显示go版本信息,则表示成功安装。2. 设置 GOPATH在任意磁盘根目录新建一个文件夹,名字随意,这个将会是我们的工作目录。我把它命名为 newgonewgo 目录下新建三个目录:binpkgsrc之后在“计算机”---“属性”-- 阅读全文

posted @ 2013-09-06 14:00 codestyle 阅读(406) 评论(0) 推荐(0) 编辑

go语言单元测试demo
摘要:package mymathfunc Add(a, b int) int { return a + b}func Max(a, b int) (ret int) { ret = a if b > a { ret = b } return}package mymath_testimport ( "mymath" "testing")type mathTest struct { a, b, ret int}var addTest = []mathTest{ mathTest{4, 6, 10}, mathTest{5, 6,... 阅读全文

posted @ 2013-06-03 17:14 codestyle 阅读(293) 评论(0) 推荐(0) 编辑

go语言的“MSDN”(ubuntu12 && 通过apt-get安装的go语言)
摘要:环境:ubuntu12 && 通过apt-get安装的go语言之前了解了python查看帮助文档的方式,感觉go也应该有他自己的帮助文档,就尝试打开它的文档,发现有godoc命令。运行之,命令提醒,可以这样运行文档godoc -http=:6060但是提示我文档不存在(不存在某个HTML文件)我就想起来上次是通过apt-get安装的,很可能安装程序的时候没有下载文档,那么只好先找找ubuntu的源里有没有godoc的相关信息,发现还真的有,那么安装下载,之后就可以用了godoc -http=:6060# no filessudo apt-cache search godoc#o 阅读全文

posted @ 2013-05-19 18:37 codestyle 阅读(471) 评论(0) 推荐(0) 编辑

go:数组
摘要:package mainimport "fmt"import "unsafe"type Employee struct{name string; age int} func displayName(e *Employee){ fmt.Printf("employee name is %s ,age is %d\n",(*e).name,(*e).age)}func main() { var e = [2]Employee{{"shujun.li",30},{"qiuming.tan",30}} 阅读全文

posted @ 2013-05-14 12:26 codestyle 阅读(164) 评论(0) 推荐(0) 编辑

go:指针初步
摘要:package mainimport "fmt"type Employee struct{name string; age int} func displayName(e *Employee){ fmt.Printf("employee name is %s ,age is\n",(*e).name)}func main() { var e1 Employee e1.name = "shujun.li" e1.age = 30 displayName(&e1) e2 := Employee{"tan qiu ming 阅读全文

posted @ 2013-05-14 12:15 codestyle 阅读(140) 评论(0) 推荐(0) 编辑

mac上安装go语言
摘要:我将在mac os x的开发机器上安装go语言的开发环境。go语言运行包下载地址:http://code.google.com/p/go/downloads/list这里我选择安装go1.0.3.darwin-amd64.pkg在mac上点击安装,运行包自动安装到/usr/local/go中,这样在命令终端就可以运行go命令了这里,我把go编辑器安装到我的xcode应用程序中,由于我的xcode装的是4.x以上在/usr/local/go/misc中,可以看到有很多编辑器版本,这里找到xcode目录,里面进入4,有个go4xcode.sh在终端中输入:sudosh./go4xcode.sh也许 阅读全文

posted @ 2013-05-13 22:48 codestyle 阅读(361) 评论(0) 推荐(0) 编辑

go : 结构
摘要:1 package main 2 3 import "fmt" 4 5 type Employee struct{name string; age int} 6 //我在这里晕了一下,还认为是逗号分隔的 7 8 9 func displayName(e Employee){10 //函数参数里的变量不需要var,且{写在定义行里11 12 fmt.Printf(e.name + "\n")13 }14 15 func main() {16 var e1 Employee17 e1.name = "shujun.li"18 e1.age 阅读全文

posted @ 2013-05-13 17:30 codestyle 阅读(187) 评论(0) 推荐(0) 编辑

编译安装go语言(ubuntu)
摘要:vi ~/.bashrc#在文件末尾追加如下环境变量#export GOROOT=$HOME/go#export GOARCH=386#export GOOS=linux#export GOBIN=$HOME/binhg#提示无效的命令 让执行下面的命令 可以获得hgsudo apt-get install mercurialhg clone -r release https://go.googlecode.com/hg/ $GOROOTcd $GOROOT/src./all.bash不过ubuntu似乎直接支持安装:sudo apt-get install golang-go~/.bashr 阅读全文

posted @ 2012-08-18 17:39 codestyle 阅读(573) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示