HarrySun

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  go

摘要:断断续续学习golang 已经有大半年了。几次涉猎过golang net package, 去年也用过Beego,但是总觉得自己只知皮毛,不能精通。所以,这次誓将其一举拿下。达到知道其宏观组织结构,又了解实现细节,甚至设计时各种考虑以及折中。目标树立好了,后面的就靠实践了。学习也要有计划,有条理。规... 阅读全文
posted @ 2015-04-11 18:10 HarrySun 阅读(439) 评论(0) 推荐(0)

摘要:学习java的时候,“设计模式”这个概念到处可见。比如java.io里面的 decorated pattern,Object.Clone(Object)原生态支持Prototype pattern,Swing事件响应的Observer pattern, io.util和Event中的Adapte... 阅读全文
posted @ 2015-04-08 01:30 HarrySun 阅读(670) 评论(0) 推荐(0)

摘要:Let's make some fun to simulation Server - Client.1. socketI implement a echo server and use telnet to simulate the socket client.in this way, we don'... 阅读全文
posted @ 2015-03-21 14:00 HarrySun 阅读(384) 评论(0) 推荐(0)

摘要:1. install and config 1). install ubuntu use samba to enable win7 users accessing ubuntu share folder. refer tohttp://www.7tutorials.com/how-cha... 阅读全文
posted @ 2015-02-27 22:51 HarrySun 阅读(341) 评论(0) 推荐(0)

摘要:0. create a string two ways to create a string 1) string([]byte) 2) str := "abc"1. Kinds of operation1) string converting to other and other conver... 阅读全文
posted @ 2014-12-29 23:22 HarrySun 阅读(373) 评论(0) 推荐(0)

摘要:1. kinds of operationIn general, there are several kinds of file operations as bellow.(1) Create file/folder, Open file, Close file, Remove file/folde... 阅读全文
posted @ 2014-12-29 23:21 HarrySun 阅读(547) 评论(0) 推荐(0)

摘要:今天试着按照上一篇博客的设计自己实现自己的crawler, 踩了一路坑。有些找到了答案,有些没有。我先将这些坑记录下来,然后divide and conquer。code snippet 1 package util 2 3 import ( 4 "math" 5 "sync" 6... 阅读全文
posted @ 2014-12-06 18:31 HarrySun 阅读(2543) 评论(1) 推荐(0)

摘要:最近看了《Go并发编程实战》,学了最后一章的crawler。这是一个很好的demo, 设计功能完备,同时具有可扩展性。根据学到的思路简单总结一下,同时重复发明一下轮子。Version 01:比如:我们想爬一下一个外贸网站所有的 商品。其中,有三个component,(1) Downloader, 用... 阅读全文
posted @ 2014-12-04 23:52 HarrySun 阅读(697) 评论(0) 推荐(0)

摘要:1. router in golang1). sample code 1 package main 2 3 import ( 4 "fmt" 5 "net/http" 6 ) 7 8 func main() { 9 10 http.HandleFunc("/handlef... 阅读全文
posted @ 2014-11-06 21:31 HarrySun 阅读(506) 评论(0) 推荐(0)

摘要:1. environment for gowe don't need to set GOROOT, seehttp://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-reallyJust add the following lines ... 阅读全文
posted @ 2014-10-12 00:29 HarrySun 阅读(274) 评论(0) 推荐(0)

摘要:断断续续理了一下关于channel的一些概念,现在可以把下面的程序理清楚了。1. source code这个程序来自于《Go语言程序设计》 7.2.2 并发的Grep, 程序如下。package mainimport ( "bufio" "bytes" "fmt" "io" ... 阅读全文
posted @ 2014-09-19 02:37 HarrySun 阅读(880) 评论(0) 推荐(0)

摘要:I spent several hours to figure out some conceptions about channel tonight1. buffered channel and non-buffered channelbuffered channelbufferedchan := ... 阅读全文
posted @ 2014-09-19 00:45 HarrySun 阅读(154) 评论(0) 推荐(0)

摘要:I am focusing on this project: http://www.goinggo.net/2013/12/sample-web-application-using-beego-and.html this weekend.see: http://docs.mongodb.org/ma... 阅读全文
posted @ 2014-08-30 00:19 HarrySun 阅读(401) 评论(0) 推荐(0)

摘要:Recently, I study the package net/url of Golang.I was puzzled about the escape and unescape of url string.then I find a clear and accurate answer at:h... 阅读全文
posted @ 2014-08-24 23:04 HarrySun 阅读(1415) 评论(0) 推荐(0)

摘要:from 《Go语言.云动力》 1 package main 2 3 import ( 4 "io" 5 "log" 6 "net/http" 7 "os" 8 "os/exec" 9 "strconv" 10 ) 11 12 v... 阅读全文
posted @ 2014-08-20 01:31 HarrySun 阅读(240) 评论(0) 推荐(0)

摘要:I list some questions in Go in my daily life and the corresponding answer.QA 1.the reader <-channel will be blocked until the writer write the channel... 阅读全文
posted @ 2014-07-07 00:31 HarrySun 阅读(346) 评论(0) 推荐(0)

摘要:1. gocrawl 类结构 1 // The crawler itself, the master of the whole process 2 type Crawler struct { 3 Options *Options 4 5 // Internal fields 6 ... 阅读全文
posted @ 2014-06-20 01:03 HarrySun 阅读(856) 评论(0) 推荐(0)

摘要:1. install beegoFirstly, I have installed Go and set the enviroment and set PATH.However, I fail to download github.com/astaxie/beego.solution: install git and set the PATH asC:\Program Files (x86)\Git\binthen rund:>go get github.com/astaxie/beegothen the files are created as 2.install bee and ad 阅读全文
posted @ 2014-04-12 01:06 HarrySun 阅读(263) 评论(0) 推荐(0)

摘要:1. install go2. configure sublimehttp://blog.csdn.net/cyxcw1/article/details/103294813.io package1) io.Reader 1 // io.Reader 接口示例 2 package main 3 4 import ( 5 "fmt" 6 "io" 7 "os" 8 "strings" 9 )10 11 func main() {12 FOREND:13 for {14 readerMenu()15 16 var ch 阅读全文
posted @ 2014-02-15 02:39 HarrySun 阅读(425) 评论(0) 推荐(0)