├── images ├── ja ├── images ├── ebook │ ├── src │ ├── build.go │ ├── build.sh │ ├── README.md │ ├── images │ │ ├── cover.png │ │ ├── ebook.jpg │ │ ├── navi1.png │ │ ├── navi2.png │ │ ├── navi3.png │ │ ├── navi4.png │ │ ├── navi5.png │ │ ├── navi6.png │ │ ├── navi7.png │ │ ├── navi8.png │ │ ├── navi9.png │ │ ├── 1.1.cmd.png │ │ ├── 1.1.mac.png │ │ ├── 1.3.go.png │ │ ├── 1.4.vim.png │ │ ├── 2.3.init.png │ │ ├── 3.1.dns2.png │ │ ├── 3.1.http.png │ │ ├── 3.1.web.png │ │ ├── 3.1.web2.png │ │ ├── 3.3.http.png │ │ ├── 8.3.rest.png │ │ ├── 8.4.rpc.png │ │ ├── 9.1.csrf.png │ │ ├── alipay.png │ │ ├── navi10.png │ │ ├── navi11.png │ │ ├── navi12.png │ │ ├── navi13.png │ │ ├── navi14.png │ │ ├── polling.png │ │ ├── 1.1.linux.png │ │ ├── 1.4.emacs.png │ │ ├── 1.4.idea1.png │ │ ├── 1.4.idea2.png │ │ ├── 1.4.idea3.png │ │ ├── 1.4.idea4.png │ │ ├── 1.4.idea5.png │ │ ├── 13.1.flow.png │ │ ├── 13.4.beego.png │ │ ├── 14.6.pprof.png │ │ ├── 2.2.array.png │ │ ├── 2.2.basic.png │ │ ├── 2.2.slice.png │ │ ├── 2.2.slice2.png │ │ ├── 3.2.goweb.png │ │ ├── 4.1.login.png │ │ ├── 4.1.slice.png │ │ ├── 4.3.escape.png │ │ ├── 4.4.token.png │ │ ├── 4.5.upload.png │ │ ├── 6.1.cookie.png │ │ ├── 6.4.cookie.png │ │ ├── 6.4.hijack.png │ │ ├── 8.1.socket.png │ │ ├── 8.3.rest2.png │ │ ├── 8.3.rest3.png │ │ ├── 1.4.eclipse1.png │ │ ├── 1.4.eclipse2.png │ │ ├── 1.4.eclipse3.png │ │ ├── 1.4.eclipse4.png │ │ ├── 1.4.eclipse5.png │ │ ├── 1.4.eclipse6.png │ │ ├── 1.4.liteide.png │ │ ├── 1.4.sublime1.png │ │ ├── 1.4.sublime2.png │ │ ├── 1.4.sublime3.png │ │ ├── 1.4.sublime4.png │ │ ├── 13.1.gopath.png │ │ ├── 13.1.gopath2.png │ │ ├── 14.4.github.png │ │ ├── 14.4.github2.png │ │ ├── 14.4.github3.png │ │ ├── 14.6.pprof2.png │ │ ├── 14.6.pprof3.png │ │ ├── 2.2.makenew.png │ │ ├── 3.1.httpPOST.png │ │ ├── 3.1.response.png │ │ ├── 4.5.upload2.png │ │ ├── 5.6.mongodb.png │ │ ├── 6.1.cookie2.png │ │ ├── 6.1.session.png │ │ ├── 6.4.setcookie.png │ │ ├── 7.4.template.png │ │ ├── 8.2.websocket.png │ │ ├── 14.1.bootstrap.png │ │ ├── 14.1.bootstrap2.png │ │ ├── 14.1.bootstrap3.png │ │ ├── 3.1.dns_inquery.png │ │ ├── 3.3.illustrator.png │ │ ├── 8.2.websocket2.png │ │ ├── 8.2.websocket3.png │ │ ├── 2.4.student_struct.png │ │ ├── 3.1.dns_hierachy.png │ │ ├── 6.4.hijacksuccess.png │ │ ├── 2.5.rect_func_without_receiver.png │ │ ├── 2.5.shapes_func_with_receiver_cp.png │ │ └── 2.5.shapes_func_without_receiver.png │ ├── config │ ├── 07.7.md │ ├── 03.5.md │ ├── 10.4.md │ ├── 03.0.md │ ├── 04.6.md │ ├── 06.5.md │ ├── 13.6.md │ ├── 01.5.md │ ├── 08.5.md │ ├── 05.7.md │ ├── 09.7.md │ ├── 11.4.md │ ├── 12.0.md │ ├── 02.0.md │ ├── 12.5.md │ ├── ref.md │ ├── 14.0.md │ ├── 01.0.md │ ├── 05.0.md │ ├── 14.7.md │ ├── 06.0.md │ ├── 07.0.md │ ├── 13.0.md │ ├── 04.0.md │ ├── 02.8.md │ ├── 11.0.md │ ├── 10.0.md │ ├── 08.0.md │ └── 09.0.md └── glossary.md ├── .gitignore ├── ebook ├── README.md ├── images │ ├── 1.3.go.png │ ├── alipay.png │ ├── cover.png │ ├── ebook.jpg │ ├── navi1.png │ ├── navi10.png │ ├── navi11.png │ ├── navi12.png │ ├── navi13.png │ ├── navi14.png │ ├── navi2.png │ ├── navi3.png │ ├── navi4.png │ ├── navi5.png │ ├── navi6.png │ ├── navi7.png │ ├── navi8.png │ ├── navi9.png │ ├── 1.1.cmd.png │ ├── 1.1.mac.png │ ├── 1.4.vim.png │ ├── 2.3.init.png │ ├── 3.1.dns2.png │ ├── 3.1.http.png │ ├── 3.1.web.png │ ├── 3.1.web2.png │ ├── 3.3.http.png │ ├── 8.3.rest.png │ ├── 8.4.rpc.png │ ├── 9.1.csrf.png │ ├── polling.png │ ├── 1.1.linux.png │ ├── 1.4.emacs.png │ ├── 1.4.idea1.png │ ├── 1.4.idea2.png │ ├── 1.4.idea3.png │ ├── 1.4.idea4.png │ ├── 1.4.idea5.png │ ├── 1.4.liteide.png │ ├── 13.1.flow.png │ ├── 13.1.gopath.png │ ├── 13.4.beego.png │ ├── 14.4.github.png │ ├── 14.6.pprof.png │ ├── 14.6.pprof2.png │ ├── 14.6.pprof3.png │ ├── 2.2.array.png │ ├── 2.2.basic.png │ ├── 2.2.makenew.png │ ├── 2.2.slice.png │ ├── 2.2.slice2.png │ ├── 3.2.goweb.png │ ├── 4.1.login.png │ ├── 4.1.slice.png │ ├── 4.3.escape.png │ ├── 4.4.token.png │ ├── 4.5.upload.png │ ├── 4.5.upload2.png │ ├── 5.6.mongodb.png │ ├── 6.1.cookie.png │ ├── 6.1.cookie2.png │ ├── 6.1.session.png │ ├── 6.4.cookie.png │ ├── 6.4.hijack.png │ ├── 8.1.socket.png │ ├── 8.3.rest2.png │ ├── 8.3.rest3.png │ ├── 1.4.eclipse1.png │ ├── 1.4.eclipse2.png │ ├── 1.4.eclipse3.png │ ├── 1.4.eclipse4.png │ ├── 1.4.eclipse5.png │ ├── 1.4.eclipse6.png │ ├── 1.4.sublime1.png │ ├── 1.4.sublime2.png │ ├── 1.4.sublime3.png │ ├── 1.4.sublime4.png │ ├── 13.1.gopath2.png │ ├── 14.4.github2.png │ ├── 14.4.github3.png │ ├── 3.1.httpPOST.png │ ├── 3.1.response.png │ ├── 6.4.setcookie.png │ ├── 7.4.template.png │ ├── 8.2.websocket.png │ ├── 14.1.bootstrap.png │ ├── 14.1.bootstrap2.png │ ├── 14.1.bootstrap3.png │ ├── 3.1.dns_hierachy.png │ ├── 3.1.dns_inquery.png │ ├── 3.3.illustrator.png │ ├── 8.2.websocket2.png │ ├── 8.2.websocket3.png │ ├── 2.4.student_struct.png │ ├── 6.4.hijacksuccess.png │ ├── 2.5.rect_func_without_receiver.png │ ├── 2.5.shapes_func_with_receiver_cp.png │ └── 2.5.shapes_func_without_receiver.png ├── src │ └── 1.2 │ │ ├── sqrt.go │ │ └── main.go ├── 07.7.md ├── 03.5.md ├── 10.4.md ├── 03.0.md ├── 04.6.md ├── 06.5.md ├── 13.6.md ├── 01.5.md ├── 11.4.md ├── 08.5.md ├── 09.7.md ├── 05.7.md ├── 12.0.md ├── 12.5.md ├── 14.0.md ├── 14.7.md ├── 02.0.md ├── 05.0.md ├── 13.0.md ├── 01.0.md ├── ref.md ├── 07.0.md ├── 06.0.md ├── 11.0.md ├── 04.0.md ├── 10.0.md ├── 09.0.md ├── 02.8.md ├── 08.0.md ├── build.sh └── 02.1.md ├── en ├── eBook │ ├── images │ │ ├── cover.png │ │ ├── ebook.jpg │ │ ├── navi1.png │ │ ├── navi2.png │ │ ├── navi3.png │ │ ├── navi4.png │ │ ├── navi5.png │ │ ├── navi6.png │ │ ├── navi7.png │ │ ├── navi8.png │ │ ├── navi9.png │ │ ├── 1.1.cmd.png │ │ ├── 1.1.mac.png │ │ ├── 1.3.go.png │ │ ├── 1.4.vim.png │ │ ├── 2.3.init.png │ │ ├── 3.1.dns2.png │ │ ├── 3.1.http.png │ │ ├── 3.1.web.png │ │ ├── 3.1.web2.png │ │ ├── 3.3.http.png │ │ ├── 8.3.rest.png │ │ ├── 8.4.rpc.png │ │ ├── 9.1.csrf.png │ │ ├── navi10.png │ │ ├── navi11.png │ │ ├── navi12.png │ │ ├── navi13.png │ │ ├── navi14.png │ │ ├── polling.png │ │ ├── 1.1.linux.png │ │ ├── 1.4.emacs.png │ │ ├── 1.4.idea1.png │ │ ├── 1.4.idea2.png │ │ ├── 1.4.idea3.png │ │ ├── 1.4.idea4.png │ │ ├── 1.4.idea5.png │ │ ├── 13.1.flow.png │ │ ├── 13.4.beego.png │ │ ├── 14.6.pprof.png │ │ ├── 2.2.array.png │ │ ├── 2.2.basic.png │ │ ├── 2.2.slice.png │ │ ├── 2.2.slice2.png │ │ ├── 3.2.goweb.png │ │ ├── 4.1.login.png │ │ ├── 4.1.slice.png │ │ ├── 4.3.escape.png │ │ ├── 4.4.token.png │ │ ├── 4.5.upload.png │ │ ├── 6.1.cookie.png │ │ ├── 6.4.cookie.png │ │ ├── 6.4.hijack.png │ │ ├── 8.1.socket.png │ │ ├── 8.3.rest2.png │ │ ├── 8.3.rest3.png │ │ ├── 1.4.eclipse1.png │ │ ├── 1.4.eclipse2.png │ │ ├── 1.4.eclipse3.png │ │ ├── 1.4.eclipse4.png │ │ ├── 1.4.eclipse5.png │ │ ├── 1.4.eclipse6.png │ │ ├── 1.4.liteide.png │ │ ├── 1.4.sublime1.png │ │ ├── 1.4.sublime2.png │ │ ├── 1.4.sublime3.png │ │ ├── 1.4.sublime4.png │ │ ├── 13.1.gopath.png │ │ ├── 13.1.gopath2.png │ │ ├── 14.4.github.png │ │ ├── 14.4.github2.png │ │ ├── 14.4.github3.png │ │ ├── 14.6.pprof2.png │ │ ├── 14.6.pprof3.png │ │ ├── 2.2.makenew.png │ │ ├── 3.1.httpPOST.png │ │ ├── 3.1.response.png │ │ ├── 4.5.upload2.png │ │ ├── 5.6.mongodb.png │ │ ├── 6.1.cookie2.png │ │ ├── 6.1.session.png │ │ ├── 6.4.setcookie.png │ │ ├── 7.4.template.png │ │ ├── 8.2.websocket.png │ │ ├── 14.1.bootstrap.png │ │ ├── 14.1.bootstrap2.png │ │ ├── 14.1.bootstrap3.png │ │ ├── 3.1.dns_inquery.png │ │ ├── 3.3.illustrator.png │ │ ├── 8.2.websocket2.png │ │ ├── 8.2.websocket3.png │ │ ├── 2.4.student_struct.png │ │ ├── 3.1.dns_hierachy.png │ │ ├── 6.4.hijacksuccess.png │ │ ├── 2.5.rect_func_without_receiver.png │ │ ├── 2.5.shapes_func_with_receiver_cp.png │ │ └── 2.5.shapes_func_without_receiver.png │ ├── 03.5.md │ ├── 04.6.md │ ├── 03.0.md │ ├── 07.7.md │ ├── ref.md │ ├── 01.5.md │ ├── 05.7.md │ ├── 10.4.md │ ├── 06.5.md │ ├── 13.6.md │ ├── 02.0.md │ ├── 11.4.md │ ├── 05.0.md │ ├── 12.0.md │ ├── 12.5.md │ ├── 06.0.md │ ├── 08.5.md │ ├── 07.0.md │ ├── 14.0.md │ ├── 09.7.md │ ├── 02.8.md │ ├── 01.0.md │ ├── 04.0.md │ ├── 14.7.md │ └── 13.0.md └── code │ ├── src │ ├── apps │ │ ├── ch.5.3 │ │ │ ├── foo.db │ │ │ ├── schema.sql │ │ │ └── readme.md │ │ ├── ch.2.3 │ │ │ ├── import_packages │ │ │ │ ├── only_call_init │ │ │ │ │ └── only_call_init.go │ │ │ │ └── main.go │ │ │ ├── hidden_print_methods │ │ │ │ └── main.go │ │ │ ├── variadic_functions │ │ │ │ └── main.go │ │ │ ├── basic_functions │ │ │ │ └── main.go │ │ │ ├── panic_and_recover │ │ │ │ └── main.go │ │ │ ├── pass_by_value_and_pointer │ │ │ │ └── main.go │ │ │ └── type_function │ │ │ │ └── main.go │ │ ├── ch.2.2 │ │ │ └── what_is_wrong_with_this │ │ │ │ └── main.go │ │ ├── ch.5.2 │ │ │ ├── schema.sql │ │ │ └── readme.md │ │ ├── ch.5.4 │ │ │ ├── schema.sql │ │ │ └── readme.md │ │ ├── ch.5.6 │ │ │ ├── mongodb │ │ │ │ ├── readme.md │ │ │ │ └── main.go │ │ │ └── redis │ │ │ │ ├── readme.md │ │ │ │ └── main.go │ │ ├── ch.4.1 │ │ │ ├── login.gtpl │ │ │ └── main.go │ │ ├── ch.4.2 │ │ │ └── submission.gtpl │ │ ├── ch.5.5 │ │ │ ├── schema.sql │ │ │ └── readme.md │ │ ├── ch.2.7 │ │ │ ├── buffered_channel │ │ │ │ └── main.go │ │ │ ├── goroutine │ │ │ │ └── main.go │ │ │ ├── range_and_close_channel │ │ │ │ └── main.go │ │ │ ├── timeout │ │ │ │ └── main.go │ │ │ ├── unbuffered_channel │ │ │ │ └── main.go │ │ │ └── select_channel │ │ │ │ └── main.go │ │ ├── ch.4.5 │ │ │ ├── upload.gtpl │ │ │ ├── index.gtpl │ │ │ ├── client_upload │ │ │ │ └── main.go │ │ │ └── nonce │ │ │ │ └── main.go │ │ ├── ch.4.4 │ │ │ ├── submission.gtpl │ │ │ ├── main.go │ │ │ └── nonce │ │ │ │ └── main.go │ │ ├── ch.2.5 │ │ │ ├── pass_struct_to_method │ │ │ │ └── main.go │ │ │ ├── embedded_method │ │ │ │ └── main.go │ │ │ ├── method_overload │ │ │ │ └── main.go │ │ │ ├── attach_methods_to_struct │ │ │ │ └── main.go │ │ │ └── box_example │ │ │ │ └── main.go │ │ ├── ch.2.1 │ │ │ └── main.go │ │ ├── ch.2.6 │ │ │ ├── stringer_interface │ │ │ │ └── main.go │ │ │ ├── reflection │ │ │ │ └── main.go │ │ │ ├── switch_type_check │ │ │ │ └── main.go │ │ │ └── type_check │ │ │ │ └── main.go │ │ ├── ch.1.2 │ │ │ └── main.go │ │ ├── ch.3.4 │ │ │ └── main.go │ │ ├── ch.2.4 │ │ │ ├── embedded_structs_with_name_conflict │ │ │ │ └── main.go │ │ │ ├── main.go │ │ │ ├── embedded_structs │ │ │ │ └── main.go │ │ │ ├── embedded_structs2 │ │ │ │ └── main.go │ │ │ └── compare_age │ │ │ │ └── main.go │ │ ├── ch.4.3 │ │ │ ├── index.gtpl │ │ │ └── main.go │ │ └── ch.3.2 │ │ │ └── main.go │ └── mymath │ │ └── sqrt.go │ └── readme.md └── LICENSE.md /images: -------------------------------------------------------------------------------- 1 | ebook/images/ -------------------------------------------------------------------------------- /ja/images: -------------------------------------------------------------------------------- 1 | ebook/images/ -------------------------------------------------------------------------------- /ja/ebook/src: -------------------------------------------------------------------------------- 1 | ../../ebook/src -------------------------------------------------------------------------------- /ja/ebook/build.go: -------------------------------------------------------------------------------- 1 | ../../ebook/build.go -------------------------------------------------------------------------------- /ja/ebook/build.sh: -------------------------------------------------------------------------------- 1 | ../../ebook/build.sh -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | pkg/* 3 | *.html 4 | *.exe 5 | 6 | -------------------------------------------------------------------------------- /ebook/README.md: -------------------------------------------------------------------------------- 1 | # Go Web 编程 2 | Go web编程是因为我喜欢Web编程,所以写了这本书,希望大家喜欢 -------------------------------------------------------------------------------- /ja/ebook/README.md: -------------------------------------------------------------------------------- 1 | # Go Web プログラミング 2 | Webプログラミングが好きでGo webプログラミングを書きました。皆さんに気にいってもらえれば幸いです。 3 | -------------------------------------------------------------------------------- /ebook/images/1.3.go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.3.go.png -------------------------------------------------------------------------------- /ebook/images/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/alipay.png -------------------------------------------------------------------------------- /ebook/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/cover.png -------------------------------------------------------------------------------- /ebook/images/ebook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/ebook.jpg -------------------------------------------------------------------------------- /ebook/images/navi1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi1.png -------------------------------------------------------------------------------- /ebook/images/navi10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi10.png -------------------------------------------------------------------------------- /ebook/images/navi11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi11.png -------------------------------------------------------------------------------- /ebook/images/navi12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi12.png -------------------------------------------------------------------------------- /ebook/images/navi13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi13.png -------------------------------------------------------------------------------- /ebook/images/navi14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi14.png -------------------------------------------------------------------------------- /ebook/images/navi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi2.png -------------------------------------------------------------------------------- /ebook/images/navi3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi3.png -------------------------------------------------------------------------------- /ebook/images/navi4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi4.png -------------------------------------------------------------------------------- /ebook/images/navi5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi5.png -------------------------------------------------------------------------------- /ebook/images/navi6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi6.png -------------------------------------------------------------------------------- /ebook/images/navi7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi7.png -------------------------------------------------------------------------------- /ebook/images/navi8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi8.png -------------------------------------------------------------------------------- /ebook/images/navi9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/navi9.png -------------------------------------------------------------------------------- /ebook/images/1.1.cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.1.cmd.png -------------------------------------------------------------------------------- /ebook/images/1.1.mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.1.mac.png -------------------------------------------------------------------------------- /ebook/images/1.4.vim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.vim.png -------------------------------------------------------------------------------- /ebook/images/2.3.init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.3.init.png -------------------------------------------------------------------------------- /ebook/images/3.1.dns2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.dns2.png -------------------------------------------------------------------------------- /ebook/images/3.1.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.http.png -------------------------------------------------------------------------------- /ebook/images/3.1.web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.web.png -------------------------------------------------------------------------------- /ebook/images/3.1.web2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.web2.png -------------------------------------------------------------------------------- /ebook/images/3.3.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.3.http.png -------------------------------------------------------------------------------- /ebook/images/8.3.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.3.rest.png -------------------------------------------------------------------------------- /ebook/images/8.4.rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.4.rpc.png -------------------------------------------------------------------------------- /ebook/images/9.1.csrf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/9.1.csrf.png -------------------------------------------------------------------------------- /ebook/images/polling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/polling.png -------------------------------------------------------------------------------- /en/eBook/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/cover.png -------------------------------------------------------------------------------- /en/eBook/images/ebook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/ebook.jpg -------------------------------------------------------------------------------- /en/eBook/images/navi1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi1.png -------------------------------------------------------------------------------- /en/eBook/images/navi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi2.png -------------------------------------------------------------------------------- /en/eBook/images/navi3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi3.png -------------------------------------------------------------------------------- /en/eBook/images/navi4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi4.png -------------------------------------------------------------------------------- /en/eBook/images/navi5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi5.png -------------------------------------------------------------------------------- /en/eBook/images/navi6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi6.png -------------------------------------------------------------------------------- /en/eBook/images/navi7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi7.png -------------------------------------------------------------------------------- /en/eBook/images/navi8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi8.png -------------------------------------------------------------------------------- /en/eBook/images/navi9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi9.png -------------------------------------------------------------------------------- /ja/ebook/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/cover.png -------------------------------------------------------------------------------- /ja/ebook/images/ebook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/ebook.jpg -------------------------------------------------------------------------------- /ja/ebook/images/navi1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi1.png -------------------------------------------------------------------------------- /ja/ebook/images/navi2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi2.png -------------------------------------------------------------------------------- /ja/ebook/images/navi3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi3.png -------------------------------------------------------------------------------- /ja/ebook/images/navi4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi4.png -------------------------------------------------------------------------------- /ja/ebook/images/navi5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi5.png -------------------------------------------------------------------------------- /ja/ebook/images/navi6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi6.png -------------------------------------------------------------------------------- /ja/ebook/images/navi7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi7.png -------------------------------------------------------------------------------- /ja/ebook/images/navi8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi8.png -------------------------------------------------------------------------------- /ja/ebook/images/navi9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi9.png -------------------------------------------------------------------------------- /ebook/images/1.1.linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.1.linux.png -------------------------------------------------------------------------------- /ebook/images/1.4.emacs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.emacs.png -------------------------------------------------------------------------------- /ebook/images/1.4.idea1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.idea1.png -------------------------------------------------------------------------------- /ebook/images/1.4.idea2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.idea2.png -------------------------------------------------------------------------------- /ebook/images/1.4.idea3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.idea3.png -------------------------------------------------------------------------------- /ebook/images/1.4.idea4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.idea4.png -------------------------------------------------------------------------------- /ebook/images/1.4.idea5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.idea5.png -------------------------------------------------------------------------------- /ebook/images/1.4.liteide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.liteide.png -------------------------------------------------------------------------------- /ebook/images/13.1.flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/13.1.flow.png -------------------------------------------------------------------------------- /ebook/images/13.1.gopath.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/13.1.gopath.png -------------------------------------------------------------------------------- /ebook/images/13.4.beego.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/13.4.beego.png -------------------------------------------------------------------------------- /ebook/images/14.4.github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.4.github.png -------------------------------------------------------------------------------- /ebook/images/14.6.pprof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.6.pprof.png -------------------------------------------------------------------------------- /ebook/images/14.6.pprof2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.6.pprof2.png -------------------------------------------------------------------------------- /ebook/images/14.6.pprof3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.6.pprof3.png -------------------------------------------------------------------------------- /ebook/images/2.2.array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.2.array.png -------------------------------------------------------------------------------- /ebook/images/2.2.basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.2.basic.png -------------------------------------------------------------------------------- /ebook/images/2.2.makenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.2.makenew.png -------------------------------------------------------------------------------- /ebook/images/2.2.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.2.slice.png -------------------------------------------------------------------------------- /ebook/images/2.2.slice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.2.slice2.png -------------------------------------------------------------------------------- /ebook/images/3.2.goweb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.2.goweb.png -------------------------------------------------------------------------------- /ebook/images/4.1.login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.1.login.png -------------------------------------------------------------------------------- /ebook/images/4.1.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.1.slice.png -------------------------------------------------------------------------------- /ebook/images/4.3.escape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.3.escape.png -------------------------------------------------------------------------------- /ebook/images/4.4.token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.4.token.png -------------------------------------------------------------------------------- /ebook/images/4.5.upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.5.upload.png -------------------------------------------------------------------------------- /ebook/images/4.5.upload2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/4.5.upload2.png -------------------------------------------------------------------------------- /ebook/images/5.6.mongodb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/5.6.mongodb.png -------------------------------------------------------------------------------- /ebook/images/6.1.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.1.cookie.png -------------------------------------------------------------------------------- /ebook/images/6.1.cookie2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.1.cookie2.png -------------------------------------------------------------------------------- /ebook/images/6.1.session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.1.session.png -------------------------------------------------------------------------------- /ebook/images/6.4.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.4.cookie.png -------------------------------------------------------------------------------- /ebook/images/6.4.hijack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.4.hijack.png -------------------------------------------------------------------------------- /ebook/images/8.1.socket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.1.socket.png -------------------------------------------------------------------------------- /ebook/images/8.3.rest2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.3.rest2.png -------------------------------------------------------------------------------- /ebook/images/8.3.rest3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.3.rest3.png -------------------------------------------------------------------------------- /en/eBook/images/1.1.cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.1.cmd.png -------------------------------------------------------------------------------- /en/eBook/images/1.1.mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.1.mac.png -------------------------------------------------------------------------------- /en/eBook/images/1.3.go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.3.go.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.vim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.vim.png -------------------------------------------------------------------------------- /en/eBook/images/2.3.init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.3.init.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.dns2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.dns2.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.http.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.web.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.web2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.web2.png -------------------------------------------------------------------------------- /en/eBook/images/3.3.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.3.http.png -------------------------------------------------------------------------------- /en/eBook/images/8.3.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.3.rest.png -------------------------------------------------------------------------------- /en/eBook/images/8.4.rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.4.rpc.png -------------------------------------------------------------------------------- /en/eBook/images/9.1.csrf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/9.1.csrf.png -------------------------------------------------------------------------------- /en/eBook/images/navi10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi10.png -------------------------------------------------------------------------------- /en/eBook/images/navi11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi11.png -------------------------------------------------------------------------------- /en/eBook/images/navi12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi12.png -------------------------------------------------------------------------------- /en/eBook/images/navi13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi13.png -------------------------------------------------------------------------------- /en/eBook/images/navi14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/navi14.png -------------------------------------------------------------------------------- /en/eBook/images/polling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/polling.png -------------------------------------------------------------------------------- /ja/ebook/images/1.1.cmd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.1.cmd.png -------------------------------------------------------------------------------- /ja/ebook/images/1.1.mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.1.mac.png -------------------------------------------------------------------------------- /ja/ebook/images/1.3.go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.3.go.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.vim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.vim.png -------------------------------------------------------------------------------- /ja/ebook/images/2.3.init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.3.init.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.dns2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.dns2.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.http.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.web.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.web2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.web2.png -------------------------------------------------------------------------------- /ja/ebook/images/3.3.http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.3.http.png -------------------------------------------------------------------------------- /ja/ebook/images/8.3.rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.3.rest.png -------------------------------------------------------------------------------- /ja/ebook/images/8.4.rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.4.rpc.png -------------------------------------------------------------------------------- /ja/ebook/images/9.1.csrf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/9.1.csrf.png -------------------------------------------------------------------------------- /ja/ebook/images/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/alipay.png -------------------------------------------------------------------------------- /ja/ebook/images/navi10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi10.png -------------------------------------------------------------------------------- /ja/ebook/images/navi11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi11.png -------------------------------------------------------------------------------- /ja/ebook/images/navi12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi12.png -------------------------------------------------------------------------------- /ja/ebook/images/navi13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi13.png -------------------------------------------------------------------------------- /ja/ebook/images/navi14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/navi14.png -------------------------------------------------------------------------------- /ja/ebook/images/polling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/polling.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse1.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse2.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse3.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse4.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse5.png -------------------------------------------------------------------------------- /ebook/images/1.4.eclipse6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.eclipse6.png -------------------------------------------------------------------------------- /ebook/images/1.4.sublime1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.sublime1.png -------------------------------------------------------------------------------- /ebook/images/1.4.sublime2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.sublime2.png -------------------------------------------------------------------------------- /ebook/images/1.4.sublime3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.sublime3.png -------------------------------------------------------------------------------- /ebook/images/1.4.sublime4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/1.4.sublime4.png -------------------------------------------------------------------------------- /ebook/images/13.1.gopath2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/13.1.gopath2.png -------------------------------------------------------------------------------- /ebook/images/14.4.github2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.4.github2.png -------------------------------------------------------------------------------- /ebook/images/14.4.github3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.4.github3.png -------------------------------------------------------------------------------- /ebook/images/3.1.httpPOST.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.httpPOST.png -------------------------------------------------------------------------------- /ebook/images/3.1.response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.response.png -------------------------------------------------------------------------------- /ebook/images/6.4.setcookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.4.setcookie.png -------------------------------------------------------------------------------- /ebook/images/7.4.template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/7.4.template.png -------------------------------------------------------------------------------- /ebook/images/8.2.websocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.2.websocket.png -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.3/foo.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/code/src/apps/ch.5.3/foo.db -------------------------------------------------------------------------------- /en/eBook/images/1.1.linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.1.linux.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.emacs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.emacs.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.idea1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.idea1.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.idea2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.idea2.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.idea3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.idea3.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.idea4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.idea4.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.idea5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.idea5.png -------------------------------------------------------------------------------- /en/eBook/images/13.1.flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/13.1.flow.png -------------------------------------------------------------------------------- /en/eBook/images/13.4.beego.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/13.4.beego.png -------------------------------------------------------------------------------- /en/eBook/images/14.6.pprof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.6.pprof.png -------------------------------------------------------------------------------- /en/eBook/images/2.2.array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.2.array.png -------------------------------------------------------------------------------- /en/eBook/images/2.2.basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.2.basic.png -------------------------------------------------------------------------------- /en/eBook/images/2.2.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.2.slice.png -------------------------------------------------------------------------------- /en/eBook/images/2.2.slice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.2.slice2.png -------------------------------------------------------------------------------- /en/eBook/images/3.2.goweb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.2.goweb.png -------------------------------------------------------------------------------- /en/eBook/images/4.1.login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.1.login.png -------------------------------------------------------------------------------- /en/eBook/images/4.1.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.1.slice.png -------------------------------------------------------------------------------- /en/eBook/images/4.3.escape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.3.escape.png -------------------------------------------------------------------------------- /en/eBook/images/4.4.token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.4.token.png -------------------------------------------------------------------------------- /en/eBook/images/4.5.upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.5.upload.png -------------------------------------------------------------------------------- /en/eBook/images/6.1.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.1.cookie.png -------------------------------------------------------------------------------- /en/eBook/images/6.4.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.4.cookie.png -------------------------------------------------------------------------------- /en/eBook/images/6.4.hijack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.4.hijack.png -------------------------------------------------------------------------------- /en/eBook/images/8.1.socket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.1.socket.png -------------------------------------------------------------------------------- /en/eBook/images/8.3.rest2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.3.rest2.png -------------------------------------------------------------------------------- /en/eBook/images/8.3.rest3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.3.rest3.png -------------------------------------------------------------------------------- /ja/ebook/images/1.1.linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.1.linux.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.emacs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.emacs.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.idea1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.idea1.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.idea2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.idea2.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.idea3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.idea3.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.idea4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.idea4.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.idea5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.idea5.png -------------------------------------------------------------------------------- /ja/ebook/images/13.1.flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/13.1.flow.png -------------------------------------------------------------------------------- /ja/ebook/images/13.4.beego.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/13.4.beego.png -------------------------------------------------------------------------------- /ja/ebook/images/14.6.pprof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.6.pprof.png -------------------------------------------------------------------------------- /ja/ebook/images/2.2.array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.2.array.png -------------------------------------------------------------------------------- /ja/ebook/images/2.2.basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.2.basic.png -------------------------------------------------------------------------------- /ja/ebook/images/2.2.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.2.slice.png -------------------------------------------------------------------------------- /ja/ebook/images/2.2.slice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.2.slice2.png -------------------------------------------------------------------------------- /ja/ebook/images/3.2.goweb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.2.goweb.png -------------------------------------------------------------------------------- /ja/ebook/images/4.1.login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.1.login.png -------------------------------------------------------------------------------- /ja/ebook/images/4.1.slice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.1.slice.png -------------------------------------------------------------------------------- /ja/ebook/images/4.3.escape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.3.escape.png -------------------------------------------------------------------------------- /ja/ebook/images/4.4.token.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.4.token.png -------------------------------------------------------------------------------- /ja/ebook/images/4.5.upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.5.upload.png -------------------------------------------------------------------------------- /ja/ebook/images/6.1.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.1.cookie.png -------------------------------------------------------------------------------- /ja/ebook/images/6.4.cookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.4.cookie.png -------------------------------------------------------------------------------- /ja/ebook/images/6.4.hijack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.4.hijack.png -------------------------------------------------------------------------------- /ja/ebook/images/8.1.socket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.1.socket.png -------------------------------------------------------------------------------- /ja/ebook/images/8.3.rest2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.3.rest2.png -------------------------------------------------------------------------------- /ja/ebook/images/8.3.rest3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.3.rest3.png -------------------------------------------------------------------------------- /ebook/images/14.1.bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.1.bootstrap.png -------------------------------------------------------------------------------- /ebook/images/14.1.bootstrap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.1.bootstrap2.png -------------------------------------------------------------------------------- /ebook/images/14.1.bootstrap3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/14.1.bootstrap3.png -------------------------------------------------------------------------------- /ebook/images/3.1.dns_hierachy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.dns_hierachy.png -------------------------------------------------------------------------------- /ebook/images/3.1.dns_inquery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.1.dns_inquery.png -------------------------------------------------------------------------------- /ebook/images/3.3.illustrator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/3.3.illustrator.png -------------------------------------------------------------------------------- /ebook/images/8.2.websocket2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.2.websocket2.png -------------------------------------------------------------------------------- /ebook/images/8.2.websocket3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/8.2.websocket3.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse1.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse2.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse3.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse4.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse5.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.eclipse6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.eclipse6.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.liteide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.liteide.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.sublime1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.sublime1.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.sublime2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.sublime2.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.sublime3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.sublime3.png -------------------------------------------------------------------------------- /en/eBook/images/1.4.sublime4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/1.4.sublime4.png -------------------------------------------------------------------------------- /en/eBook/images/13.1.gopath.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/13.1.gopath.png -------------------------------------------------------------------------------- /en/eBook/images/13.1.gopath2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/13.1.gopath2.png -------------------------------------------------------------------------------- /en/eBook/images/14.4.github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.4.github.png -------------------------------------------------------------------------------- /en/eBook/images/14.4.github2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.4.github2.png -------------------------------------------------------------------------------- /en/eBook/images/14.4.github3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.4.github3.png -------------------------------------------------------------------------------- /en/eBook/images/14.6.pprof2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.6.pprof2.png -------------------------------------------------------------------------------- /en/eBook/images/14.6.pprof3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.6.pprof3.png -------------------------------------------------------------------------------- /en/eBook/images/2.2.makenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.2.makenew.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.httpPOST.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.httpPOST.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.response.png -------------------------------------------------------------------------------- /en/eBook/images/4.5.upload2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/4.5.upload2.png -------------------------------------------------------------------------------- /en/eBook/images/5.6.mongodb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/5.6.mongodb.png -------------------------------------------------------------------------------- /en/eBook/images/6.1.cookie2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.1.cookie2.png -------------------------------------------------------------------------------- /en/eBook/images/6.1.session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.1.session.png -------------------------------------------------------------------------------- /en/eBook/images/6.4.setcookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.4.setcookie.png -------------------------------------------------------------------------------- /en/eBook/images/7.4.template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/7.4.template.png -------------------------------------------------------------------------------- /en/eBook/images/8.2.websocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.2.websocket.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse1.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse2.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse3.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse4.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse5.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.eclipse6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.eclipse6.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.liteide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.liteide.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.sublime1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.sublime1.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.sublime2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.sublime2.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.sublime3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.sublime3.png -------------------------------------------------------------------------------- /ja/ebook/images/1.4.sublime4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/1.4.sublime4.png -------------------------------------------------------------------------------- /ja/ebook/images/13.1.gopath.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/13.1.gopath.png -------------------------------------------------------------------------------- /ja/ebook/images/13.1.gopath2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/13.1.gopath2.png -------------------------------------------------------------------------------- /ja/ebook/images/14.4.github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.4.github.png -------------------------------------------------------------------------------- /ja/ebook/images/14.4.github2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.4.github2.png -------------------------------------------------------------------------------- /ja/ebook/images/14.4.github3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.4.github3.png -------------------------------------------------------------------------------- /ja/ebook/images/14.6.pprof2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.6.pprof2.png -------------------------------------------------------------------------------- /ja/ebook/images/14.6.pprof3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.6.pprof3.png -------------------------------------------------------------------------------- /ja/ebook/images/2.2.makenew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.2.makenew.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.httpPOST.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.httpPOST.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.response.png -------------------------------------------------------------------------------- /ja/ebook/images/4.5.upload2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/4.5.upload2.png -------------------------------------------------------------------------------- /ja/ebook/images/5.6.mongodb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/5.6.mongodb.png -------------------------------------------------------------------------------- /ja/ebook/images/6.1.cookie2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.1.cookie2.png -------------------------------------------------------------------------------- /ja/ebook/images/6.1.session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.1.session.png -------------------------------------------------------------------------------- /ja/ebook/images/6.4.setcookie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.4.setcookie.png -------------------------------------------------------------------------------- /ja/ebook/images/7.4.template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/7.4.template.png -------------------------------------------------------------------------------- /ja/ebook/images/8.2.websocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.2.websocket.png -------------------------------------------------------------------------------- /ebook/images/2.4.student_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.4.student_struct.png -------------------------------------------------------------------------------- /ebook/images/6.4.hijacksuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/6.4.hijacksuccess.png -------------------------------------------------------------------------------- /en/eBook/images/14.1.bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.1.bootstrap.png -------------------------------------------------------------------------------- /en/eBook/images/14.1.bootstrap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.1.bootstrap2.png -------------------------------------------------------------------------------- /en/eBook/images/14.1.bootstrap3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/14.1.bootstrap3.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.dns_inquery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.dns_inquery.png -------------------------------------------------------------------------------- /en/eBook/images/3.3.illustrator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.3.illustrator.png -------------------------------------------------------------------------------- /en/eBook/images/8.2.websocket2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.2.websocket2.png -------------------------------------------------------------------------------- /en/eBook/images/8.2.websocket3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/8.2.websocket3.png -------------------------------------------------------------------------------- /ja/ebook/images/14.1.bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.1.bootstrap.png -------------------------------------------------------------------------------- /ja/ebook/images/14.1.bootstrap2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.1.bootstrap2.png -------------------------------------------------------------------------------- /ja/ebook/images/14.1.bootstrap3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/14.1.bootstrap3.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.dns_inquery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.dns_inquery.png -------------------------------------------------------------------------------- /ja/ebook/images/3.3.illustrator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.3.illustrator.png -------------------------------------------------------------------------------- /ja/ebook/images/8.2.websocket2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.2.websocket2.png -------------------------------------------------------------------------------- /ja/ebook/images/8.2.websocket3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/8.2.websocket3.png -------------------------------------------------------------------------------- /en/eBook/images/2.4.student_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.4.student_struct.png -------------------------------------------------------------------------------- /en/eBook/images/3.1.dns_hierachy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/3.1.dns_hierachy.png -------------------------------------------------------------------------------- /en/eBook/images/6.4.hijacksuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/6.4.hijacksuccess.png -------------------------------------------------------------------------------- /ja/ebook/images/2.4.student_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.4.student_struct.png -------------------------------------------------------------------------------- /ja/ebook/images/3.1.dns_hierachy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/3.1.dns_hierachy.png -------------------------------------------------------------------------------- /ja/ebook/images/6.4.hijacksuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/6.4.hijacksuccess.png -------------------------------------------------------------------------------- /ebook/images/2.5.rect_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.5.rect_func_without_receiver.png -------------------------------------------------------------------------------- /ebook/images/2.5.shapes_func_with_receiver_cp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.5.shapes_func_with_receiver_cp.png -------------------------------------------------------------------------------- /ebook/images/2.5.shapes_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ebook/images/2.5.shapes_func_without_receiver.png -------------------------------------------------------------------------------- /en/eBook/images/2.5.rect_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.5.rect_func_without_receiver.png -------------------------------------------------------------------------------- /ja/ebook/images/2.5.rect_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.5.rect_func_without_receiver.png -------------------------------------------------------------------------------- /en/eBook/images/2.5.shapes_func_with_receiver_cp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.5.shapes_func_with_receiver_cp.png -------------------------------------------------------------------------------- /en/eBook/images/2.5.shapes_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/en/eBook/images/2.5.shapes_func_without_receiver.png -------------------------------------------------------------------------------- /ja/ebook/images/2.5.shapes_func_with_receiver_cp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.5.shapes_func_with_receiver_cp.png -------------------------------------------------------------------------------- /ja/ebook/images/2.5.shapes_func_without_receiver.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codercheng/build-web-application-with-golang/master/ja/ebook/images/2.5.shapes_func_without_receiver.png -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/import_packages/only_call_init/only_call_init.go: -------------------------------------------------------------------------------- 1 | package only_call_init 2 | 3 | import "fmt" 4 | 5 | func init() { 6 | fmt.Println("only_call_init.init() was called.") 7 | } 8 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.3/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `userinfo` ( 2 | `uid` INTEGER PRIMARY KEY AUTOINCREMENT, 3 | `username` VARCHAR(64) NULL, 4 | `department` VARCHAR(64) NULL, 5 | `created` DATE NULL 6 | ); 7 | -------------------------------------------------------------------------------- /ebook/src/1.2/sqrt.go: -------------------------------------------------------------------------------- 1 | // 章节 1.2 2 | // $GOPATH/src/mymath/sqrt.go 3 | package mymath 4 | 5 | func Sqrt(x float64) float64 { 6 | z := 0.0 7 | for i := 0; i < 1000; i++ { 8 | z -= (z*z - x) / (2 * x) 9 | } 10 | return z 11 | } 12 | -------------------------------------------------------------------------------- /ebook/src/1.2/main.go: -------------------------------------------------------------------------------- 1 | // 章节 1.2 2 | // $GOPATH/src/mathapp/main.go 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "mymath" 9 | ) 10 | 11 | func main() { 12 | fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2)) 13 | } 14 | -------------------------------------------------------------------------------- /ja/ebook/config: -------------------------------------------------------------------------------- 1 | MSG_INSTALL_PANDOC_FIRST='pandocをインストール後、再度実行してください。' 2 | MSG_SUCCESSFULLY_GENERATED='build-web-application-with-golang.epub を作成しました' 3 | MSG_CREATOR='Astaxie' 4 | MSG_DESCRIPTION='オープンソースのGo Webプログラミング書籍' 5 | MSG_LANGUAGE='ja-JP' 6 | MSG_TITLE='Go Webプログラミング' 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.2/what_is_wrong_with_this/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.2 from "Build Web Application with Golang" 2 | // Purpose: Try to fix this program. 3 | // From the console, type `go run main.go` 4 | package main 5 | 6 | func main() { 7 | var i int 8 | } 9 | -------------------------------------------------------------------------------- /en/code/readme.md: -------------------------------------------------------------------------------- 1 | ## Workspace setup. 2 | 3 | To avoid workspace issues and be able to develop from any folder within this path, 4 | set the environment variable `GOPATH` to the path of this directory. 5 | 6 | More info: 7 | - [GOPATH documentation](http://golang.org/doc/code.html#GOPATH) 8 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.2/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `userinfo` ( 2 | `uid` INT(10) NOT NULL AUTO_INCREMENT, 3 | `username` VARCHAR(64) NULL DEFAULT NULL, 4 | `departname` VARCHAR(64) NULL DEFAULT NULL, 5 | `created` DATE NULL DEFAULT NULL, 6 | PRIMARY KEY (`uid`) 7 | ); 8 | -------------------------------------------------------------------------------- /ebook/07.7.md: -------------------------------------------------------------------------------- 1 | # 7.7 小结 2 | 这一章给大家介绍了一些文本处理的工具,包括XML、JSON、正则和模板技术,XML和JSON是数据交互的工具,通过XML和JSON你可以表达各种含义,通过正则你可以处理文本(搜索、替换、截取),通过模板技术你可以展现这些数据给用户。这些都是你开发Web应用过程中需要用到的技术,通过这个小节的介绍你能够了解如何处理文本、展现文本。 3 | 4 | ## links 5 | * [目录]() 6 | * 上一节: [字符串处理](<07.6.md>) 7 | * 下一节: [Web服务](<08.0.md>) 8 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.4/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE userinfo 2 | ( 3 | uid serial NOT NULL, 4 | username character varying(100) NOT NULL, 5 | departname character varying(500) NOT NULL, 6 | Created date, 7 | CONSTRAINT userinfo_pkey PRIMARY KEY (uid) 8 | ) 9 | WITH (OIDS=FALSE); 10 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.6/mongodb/readme.md: -------------------------------------------------------------------------------- 1 | ##Setup for `ch.5.6` for MongoDB 2 | 3 | - Step 1) Install and run MongoDB 4 | - Step 2) Launch the MongoDB daemon (mongod) to start the server. 5 | - Step 3) Run `go get` to download and install the remote packages. 6 | - Step 4) Execute the program with `go run main.go` 7 | -------------------------------------------------------------------------------- /ebook/03.5.md: -------------------------------------------------------------------------------- 1 | # 3.5 小结 2 | 这一章我们介绍了HTTP协议, DNS解析的过程, 如何用go实现一个简陋的web server。并深入到net/http包的源码中为大家揭开实现此server的秘密。 3 | 4 | 希望通过这一章的学习,你能够对Go开发Web有了初步的了解,我们也看到相应的代码了,Go开发Web应用是很方便的,同时又是相当的灵活。 5 | 6 | ## links 7 | * [目录]() 8 | * 上一节: [Go的http包详解](<03.4.md>) 9 | * 下一章: [表单](<04.0.md>) 10 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.1/login.gtpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | Username: 8 | Password: 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /ebook/10.4.md: -------------------------------------------------------------------------------- 1 | # 10.4 小结 2 | 通过这一章的介绍,读者应该对如何操作i18n有了深入的了解,我也根据这一章介绍的内容实现了一个开源的解决方案go-i18n:https://github.com/astaxie/go-i18n 通过这个开源库我们可以很方便的实现多语言版本的Web应用,使得我们的应用能够轻松的实现国际化。如果你发现这个开源库中的错误或者那些缺失的地方,请一起参与到这个开源项目中来,让我们的这个库争取成为Go的标准库。 3 | ## links 4 | * [目录]() 5 | * 上一节: [国际化站点](<10.3.md>) 6 | * 下一节: [错误处理,故障排除和测试](<11.0.md>) 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.2/submission.gtpl: -------------------------------------------------------------------------------- 1 | {{define "submission"}} 2 | 3 | 4 | {{if .Errors}} 5 |

Errors:

6 |
    7 | {{range .Errors}} 8 |
  1. {{.}}
  2. 9 | {{end}} 10 |
11 | {{else}} 12 | Profile successfully submitted. 13 | {{end}} 14 | 15 | 16 | {{end}} -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.5/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `userinfo` ( 2 | `uid` INTEGER PRIMARY KEY AUTOINCREMENT, 3 | `username` VARCHAR(64) NULL, 4 | `department` VARCHAR(64) NULL, 5 | `created` DATE NULL 6 | ); 7 | CREATE TABLE `userdetail` ( 8 | `uid` INT(10) NULL, 9 | `intro` TEXT NULL, 10 | `profile` TEXT NULL, 11 | PRIMARY KEY (`uid`) 12 | ); 13 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.6/redis/readme.md: -------------------------------------------------------------------------------- 1 | ##Setup for `ch.5.6` for Redis 2 | 3 | - Step 1) Install and run Redis 4 | - Step 2) Launch the Redis server matching the DB constants. 5 | 6 | DB_PORT = "9191" 7 | DB_URL = "127.0.0.1" 8 | 9 | - Step 3) Run `go get` to download and install the remote packages. 10 | - Step 4) Execute the program with `go run main.go` 11 | -------------------------------------------------------------------------------- /ebook/03.0.md: -------------------------------------------------------------------------------- 1 | # 3 Web基础 2 | 3 | 学习基于Web的编程可能正是你读本书的原因。事实上,如何通过Go来编写Web应用也是我编写这本书的初衷。前面已经介绍过,Go目前已经拥有了成熟的HTTP处理包,这使得编写能做任何事情的动态Web程序易如反掌。在接下来的各章中将要介绍的内容,都是属于Web编程的范畴。本章则集中讨论一些与Web相关的概念和Go如何运行Web程序的话题。 4 | 5 | ## 目录 6 | ![](images/navi3.png?raw=true) 7 | 8 | ## links 9 | * [目录]() 10 | * 上一章: [第二章总结](<02.8.md>) 11 | * 下一节: [Web工作方式](<03.1.md>) 12 | -------------------------------------------------------------------------------- /ebook/04.6.md: -------------------------------------------------------------------------------- 1 | # 4.6 小结 2 | 这一章里面我们学习了Go如何处理表单信息,我们通过用户登陆、上传文件的例子展示了Go处理form表单信息及上传文件的手段。但是在处理表单过程中我们需要验证用户输入的信息,考虑到网站安全的重要性,数据过滤就显得相当重要了,因此后面的章节中专门写了一个小节来讲解了不同方面的数据过滤,顺带讲一下Go对字符串的正则处理。 3 | 4 | 通过这一章能够让你了解客户端和服务器端是如何进行数据上的交互,客户端将数据传递给服务器系统,服务器接受数据又把处理结果反馈给客户端。 5 | 6 | ## links 7 | * [目录]() 8 | * 上一节: [处理文件上传](<04.5.md>) 9 | * 下一章: [访问数据库](<05.0.md>) 10 | -------------------------------------------------------------------------------- /ja/ebook/07.7.md: -------------------------------------------------------------------------------- 1 | # 7.7 まとめ 2 | この章ではみなさんにXML、JSON、正規表現およびテンプレートの技術といったテキスト処理のツールをいくつかご紹介しました。XMLとJSONを使って様々な意味を表現することができます。正規表現ではテキストの検索/置換/切り取りといった処理を行うことができます。テンプレート技術を使うとこれらのデータをユーザに表示させることができます。これらはどれもWebアプリケーションを開発する過程で必要となる技術です。この節のご紹介を通じてどのようにテキストを処理、表示するかご理解いただけたかと思います。 3 | 4 | ## links 5 | * [目次]() 6 | * 前へ: [文字列の処理](<07.6.md>) 7 | * 次へ: [Webサービス](<08.0.md>) 8 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/buffered_channel/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to use a buffered channel 3 | package main 4 | 5 | import "fmt" 6 | 7 | func main() { 8 | c := make(chan int, 2) // change 2 to 1 will have runtime error, but 3 is fine 9 | c <- 1 10 | c <- 2 11 | fmt.Println(<-c) 12 | fmt.Println(<-c) 13 | } 14 | -------------------------------------------------------------------------------- /ja/ebook/03.5.md: -------------------------------------------------------------------------------- 1 | # 3.5 まとめ 2 | この章ではHTTPプロトコル、DNS名前解決のプロセス、どのようにしてgoで簡単なweb serverを実装するかご紹介しました。net/httpパッケージのソースコードに触れるうちにこのserverを実装する秘密についてお分かりいただけたかと思います。 3 | 4 | この章の学習を通じて、GoによるWeb開発の初歩をご理解いただければ幸いです。我々はまた対応するコードを見ることでGoでWebアプリケーションを開発することがとても便利でまた相当柔軟であると分かりました。 5 | 6 | ## links 7 | * [目次]() 8 | * 前へ: [Goのhttpパッケージ詳細](<03.4.md>) 9 | * 次へ: [フォーム](<04.0.md>) 10 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.5/upload.gtpl: -------------------------------------------------------------------------------- 1 | {{define "upload"}} 2 | 3 | 4 | {{if .Errors}} 5 |

Errors:

6 |
    7 | {{range .Errors}} 8 |
  1. {{.}}
  2. 9 | {{end}} 10 |
11 | {{else}} 12 | File uploaded successfully.
13 | Note: Refreshing the page will produce a duplicate entry. 14 | {{end}} 15 | 16 | 17 | {{end}} 18 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.4/submission.gtpl: -------------------------------------------------------------------------------- 1 | {{define "submission"}} 2 | 3 | 4 | {{if .Errors}} 5 |

Errors:

6 |
    7 | {{range .Errors}} 8 |
  1. {{.}}
  2. 9 | {{end}} 10 |
11 | {{else}} 12 | Profile successfully submitted.
13 | Note: Refreshing the page will produce a duplicate entry. 14 | {{end}} 15 | 16 | 17 | {{end}} -------------------------------------------------------------------------------- /en/code/src/mymath/sqrt.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 1.2 from "Build Web Application with Golang" 2 | // Purpose: Shows how to create a simple package called `mymath` 3 | // This package must be imported from another go file to run. 4 | package mymath 5 | 6 | func Sqrt(x float64) float64 { 7 | z := 0.0 8 | for i := 0; i < 1000; i++ { 9 | z -= (z*z - x) / (2 * x) 10 | } 11 | return z 12 | } 13 | -------------------------------------------------------------------------------- /ebook/06.5.md: -------------------------------------------------------------------------------- 1 | # 6.5 小结 2 | 这章我们学习了什么是session,什么是cookie,以及他们两者之间的关系。但是目前Go官方标准包里面不支持session,所以我们设计了一个session管理器,实现了session从创建到销毁的整个过程。然后定义了Provider的接口,使得可以支持各种后端的session存储,然后我们在第三小节里面介绍了如何使用内存存储来实现session的管理。第四小节我们讲解了session劫持的过程,以及我们如何有效的来防止session劫持。通过这一章的讲解,希望能够让读者了解整个sesison的执行原理以及如何实现,而且是如何更加安全的使用session。 3 | ## links 4 | * [目录]() 5 | * 上一节: [session存储](<06.4.md>) 6 | * 下一章: [文本处理](<07.0.md>) 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/hidden_print_methods/main.go: -------------------------------------------------------------------------------- 1 | // As of Google go 1.1.2, `println()` and `print()` are hidden functions included from the runtime package. 2 | // However it's encouraged to use the print functions from the `fmt` package. 3 | package main 4 | 5 | import "fmt" 6 | 7 | func f() { 8 | fmt.Println("First") 9 | print("Second ") 10 | println(" Third") 11 | } 12 | func main() { 13 | f() 14 | } 15 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.5/pass_struct_to_method/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Rectangle struct { 6 | width, height float64 7 | } 8 | 9 | func area(r Rectangle) float64 { 10 | return r.width * r.height 11 | } 12 | 13 | func main() { 14 | r1 := Rectangle{12, 2} 15 | r2 := Rectangle{9, 4} 16 | fmt.Println("Area of r1 is: ", area(r1)) 17 | fmt.Println("Area of r2 is: ", area(r2)) 18 | } 19 | -------------------------------------------------------------------------------- /ebook/13.6.md: -------------------------------------------------------------------------------- 1 | # 13.6 小结 2 | 这一章我们主要介绍了如何实现一个基础的Go语言框架,框架包含有路由设计,由于Go内置的http包中路由的一些不足点,我们设计了动态路由规则,然后介绍了MVC模式中的Controller设计,controller实现了REST的实现,这个主要思路来源于tornado框架,然后设计实现了模板的layout以及自动化渲染等技术,主要采用了Go内置的模板引擎,最后我们介绍了一些辅助的日志、配置等信息的设计,通过这些设计我们实现了一个基础的框架beego,目前该框架已经开源在github,最后我们通过beego实现了一个博客系统,通过实例代码详细的展现了如何快速的开发一个站点。 3 | 4 | ## links 5 | * [目录]() 6 | * 上一章: [实现博客的增删改](<13.5.md>) 7 | * 下一节: [扩展Web框架](<14.0.md>) -------------------------------------------------------------------------------- /ebook/01.5.md: -------------------------------------------------------------------------------- 1 | # 1.5 总结 2 | 3 | 这一章中我们主要介绍了如何安装Go,Go可以通过三种方式安装:源码安装、标准包安装、第三方工具安装,安装之后我们需要配置我们的开发环境,然后介绍了如何配置本地的`$GOPATH`,通过设置`$GOPATH`之后读者就可以创建项目,接着介绍了如何来进行项目编译、应用安装等问题,这些需要用到很多Go命令,所以接着就介绍了一些Go的常用命令工具,包括编译、安装、格式化、测试等命令,最后介绍了Go的开发工具,目前有很多Go的开发工具:LiteIDE、sublime、VIM、Emacs、Eclipse、Idea等工具,读者可以根据自己熟悉的工具进行配置,希望能够通过方便的工具快速的开发Go应用。 4 | 5 | ## links 6 | * [目录]() 7 | * 上一节: [Go开发工具](<01.4.md>) 8 | * 下一章: [Go语言基础](<02.0.md>) 9 | -------------------------------------------------------------------------------- /ebook/11.4.md: -------------------------------------------------------------------------------- 1 | # 11.4 小结 2 | 本章我们通过三个小节分别介绍了Go语言中如何处理错误,如何设计错误处理,然后第二小节介绍了如何通过GDB来调试程序,通过GDB我们可以单步调试、可以查看变量、修改变量、打印执行过程等,最后我们介绍了如何利用Go语言自带的轻量级框架`testing`来编写单元测试和压力测试,使用`go test`就可以方便的执行这些测试,使得我们将来代码升级修改之后很方便的进行回归测试。这一章也许对于你编写程序逻辑没有任何帮助,但是对于你编写出来的程序代码保持高质量是至关重要的,因为一个好的Web应用必定有良好的错误处理机制(错误提示的友好、可扩展性)、有好的单元测试和压力测试以保证上线之后代码能够保持良好的性能和按预期的运行。 3 | 4 | ## links 5 | * [目录]() 6 | * 上一节: [Go怎么写测试用例](<11.3.md>) 7 | * 下一节: [部署与维护](<12.0.md>) -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.1/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter ? from "Build Web Application with Golang" 2 | // Purpose: Hello world example demonstrating UTF-8 support. 3 | // To run in the console, type `go run main.go` 4 | // You're missing language fonts, if you're seeing squares or question marks. 5 | package main 6 | 7 | import "fmt" 8 | 9 | func main() { 10 | fmt.Printf("Hello, world or 你好,世界 or καλημ ́ρα κóσμ or こんにちは世界\n") 11 | } 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.5/index.gtpl: -------------------------------------------------------------------------------- 1 | {{define "index"}} 2 | 3 | 4 | 5 | Upload file 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | {{end}} 16 | -------------------------------------------------------------------------------- /ja/ebook/10.4.md: -------------------------------------------------------------------------------- 1 | # 10.4 まとめ 2 | この章の紹介を通じて、読者はどのようにしてi18nを操作するかに対して深く理解が得られたはずです。私もこの章の内容にもとづいてオープンソースのソリューションであるgo-i18nをご紹介しました:https://github.com/astaxie/go-i18n このオープンソースライブラリを通して多言語バージョンのWebアプリケーションを非常に簡単に実現することができ、我々のアプリケーションに気楽に国際化を実現させることができます。もしこのオープンソースライブラリに間違いや足りない部分があれば、ぜひこのオープンソースプロジェクトに参加することで、このライブラリがGoの標準ライブラリになるよう手助けしてください。 3 | ## links 4 | * [目次]() 5 | * 前へ: [国際化サイト](<10.3.md>) 6 | * 次へ: [エラー処理、故障の排除とテスト](<11.0.md>) 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.2/readme.md: -------------------------------------------------------------------------------- 1 | ##Setup for `ch.5.2` 2 | 3 | - Step 1) Install and run MySql 4 | - Step 2) Create a user and database according to the constants in `main.go` 5 | 6 | DB_USER = "user" 7 | DB_PASSWORD = "" 8 | DB_NAME = "test" 9 | 10 | - Step 3) Create table `userinfo` located at `schema.sql` 11 | - Step 4) Run `go get` to download and install the remote packages. 12 | - Step 5) Execute the program with `go run main.go` 13 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.4/readme.md: -------------------------------------------------------------------------------- 1 | ##Setup for ch.5.4 2 | 3 | - Step 1) Install and run Postgres 4 | - Step 2) Create a user and database according to the constants in `main.go` 5 | 6 | DB_USER = "user" 7 | DB_PASSWORD = "" 8 | DB_NAME = "test" 9 | 10 | - Step 3) Create table `userinfo` located at `schema.sql` 11 | - Step 4) Run `go get` to download and install the remote packages. 12 | - Step 5) Execute the program with `go run main.go` 13 | -------------------------------------------------------------------------------- /ja/ebook/03.0.md: -------------------------------------------------------------------------------- 1 | # 3 Webの基礎 2 | 3 | Webのプログラミングの基礎を勉強することはあなたにとってまさにこの本を読む理由でしょう。事実、どのようにGoを使ってWebアプリケーションをプログラムするかはこの本の目的でもあります。前回までで、Goは既に成熟したHTTP処理パッケージを持つことをご紹介しました。これによってどのような事情の動的なWebプログラミングも簡単に作成できます。これ以降の章でご紹介する内容はどれもWebプログラミングの範疇です。この章ではWebに関する概念とGo言語がいかにWebプログラムを実行するかに集中して討論します。 4 | 5 | ## 目次 6 | ![](images/navi3.png?raw=true) 7 | 8 | ## links 9 | * [目次]() 10 | * 前へ: [第二章まとめ](<02.8.md>) 11 | * 次へ: [Webでの作業方法](<03.1.md>) 12 | -------------------------------------------------------------------------------- /ebook/08.5.md: -------------------------------------------------------------------------------- 1 | # 8.5 小结 2 | 这一章我们介绍了目前流行的几种主要的网络应用开发方式,第一小节介绍了网络编程中的基础:Socket编程,因为现在网络正在朝云的方向快速进化,作为这一技术演进的基石的的socket知识,作为开发者的你,是必须要掌握的。第二小节介绍了正愈发流行的HTML5中一个重要的特性WebSocket,通过它,服务器可以实现主动的push消息,以简化以前ajax轮询的模式。第三小节介绍了REST编写模式,这种模式特别适合来开发网络应用API,目前移动应用的快速发展,我觉得将来会是一个潮流。第四小节介绍了Go实现的RPC相关知识,对于上面四种开发方式,Go都已经提供了良好的支持,net包及其子包,是所有涉及到网络编程的工具的所在地。如果你想更加深入的了解相关实现细节,可以尝试阅读这个包下面的源码。 3 | ## links 4 | * [目录]() 5 | * 上一节: [RPC](<08.4.md>) 6 | * 下一章: [安全与加密](<09.0.md>) 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/goroutine/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to launch a simple gorountine 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "runtime" 8 | ) 9 | 10 | func say(s string) { 11 | for i := 0; i < 5; i++ { 12 | runtime.Gosched() 13 | fmt.Println(s) 14 | } 15 | } 16 | 17 | func main() { 18 | go say("world") // create a new goroutine 19 | say("hello") // current goroutine 20 | } 21 | -------------------------------------------------------------------------------- /ebook/09.7.md: -------------------------------------------------------------------------------- 1 | # 9.7 小结 2 | 这一章主要介绍了如:CSRF攻击、XSS攻击、SQL注入攻击等一些Web应用中典型的攻击手法,它们都是由于应用对用户的输入没有很好的过滤引起的,所以除了介绍攻击的方法外,我们也介绍了了如何有效的进行数据过滤,以防止这些攻击的发生的方法。然后针对日异严重的密码泄漏事件,介绍了在设计Web应用中可采用的从基本到专家的加密方案。最后针对敏感数据的加解密简要介绍了,Go语言提供三种对称加密算法:base64、aes和des的实现。 3 | 4 | 编写这一章的目的是希望读者能够在意识里面加强安全概念,在编写Web应用的时候多留心一点,以使我们编写的Web应用能远离黑客们的攻击。Go语言在支持防攻击方面已经提供大量的工具包,我们可以充分的利用这些包来做出一个安全的Web应用。 5 | 6 | ## links 7 | * [目录]() 8 | * 上一节: [加密和解密数据](<09.6.md>) 9 | * 下一节: [国际化和本地化](<10.0.md>) 10 | -------------------------------------------------------------------------------- /ebook/05.7.md: -------------------------------------------------------------------------------- 1 | # 5.7 小结 2 | 这一章我们讲解了Go如何设计database/sql接口,然后介绍了各种第三方关系型数据库驱动的使用。接着介绍了beedb,一种基于关系型数据库的ORM库,如何对数据库进行简单的操作。最后介绍了NOSQL的一些知识,目前Go对于NOSQL支持还是不错,因为Go作为21世纪的C语言,那么对于21世纪的数据库也是支持的相当好。 3 | 4 | 通过这一章的学习,我们学会了如何操作各种数据库,那么就解决了我们数据存储的问题,这是Web里面最重要的一部分,所以希望大家能够深入的去了解database/sql的设计思想。 5 | 6 | >[Go database/sql tutorial](http://go-database-sql.org/) 里提供了惯用的范例及详细的说明。 7 | 8 | ## links 9 | * [目录]() 10 | * 上一节: [NOSQL数据库操作](<05.6.md>) 11 | * 下一章: [session和数据存储](<06.0.md>) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.6/stringer_interface/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | type Human struct { 9 | name string 10 | age int 11 | phone string 12 | } 13 | 14 | // Human implemented fmt.Stringer 15 | func (h Human) String() string { 16 | return "Name:" + h.name + ", Age:" + strconv.Itoa(h.age) + " years, Contact:" + h.phone 17 | } 18 | 19 | func main() { 20 | Bob := Human{"Bob", 39, "000-7777-XXX"} 21 | fmt.Println("This Human is : ", Bob) 22 | } 23 | -------------------------------------------------------------------------------- /ebook/12.0.md: -------------------------------------------------------------------------------- 1 | # 12 部署与维护 2 | 到目前为止,我们前面已经介绍了如何开发程序、调试程序以及测试程序,正如人们常说的:开发最后的10%需要花费90%的时间,所以这一章我们将强调这最后的10%部分,要真正成为让人信任并使用的优秀应用,需要考虑到一些细节,以上所说的10%就是指这些小细节。 3 | 4 | 本章我们将通过四个小节来介绍这些小细节的处理,第一小节介绍如何在生产服务上记录程序产生的日志,如何记录日志,第二小节介绍发生错误时我们的程序如何处理,如何保证尽量少的影响到用户的访问,第三小节介绍如何来部署Go的独立程序,由于目前Go程序还无法像C那样写成daemon,那么我们如何管理这样的进程程序后台运行呢?第四小节将介绍应用数据的备份和恢复,尽量保证应用在崩溃的情况能够保持数据的完整性。 5 | ## 目录 6 | ![](images/navi12.png?raw=true) 7 | 8 | ## links 9 | * [目录]() 10 | * 上一章: [第十一章总结](<11.4.md>) 11 | * 下一节: [应用日志](<12.1.md>) -------------------------------------------------------------------------------- /en/code/src/apps/ch.1.2/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 1.2 from "Build Web Application with Golang" 2 | // Purpose: Run this file to check if your workspace is setup correctly. 3 | // To run, navigate to the current directory in a console and type `go run main.go` 4 | // If the text "Hello World" isn't shown, then setup your workspace again. 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "mymath" 10 | ) 11 | 12 | func main() { 13 | fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2)) 14 | } 15 | -------------------------------------------------------------------------------- /ja/ebook/04.6.md: -------------------------------------------------------------------------------- 1 | # 4.6 まとめ 2 | この一章ではGoでどのようにフォームの情報を処理するか学びました。ユーザのログインから、ファイルのアップロードの例で、Goがformの情報およびファイルをアップロードする手段についてご説明しました。しかし、フォームを処理する過程ではユーザの入力した情報を懸賞する必要があります。ホームページのセキュリティの重要性を考慮すると、データのフィルタリングは相当重要です。そのため、以降の章では異なる方面のデータフィルタリングをご説明します。同時にGoの文字列に対する正規表現についても述べます。 3 | 4 | この一章を通してクライアントとサーバが如何にデータを互いにやりとりするか理解いただけたと思います。クライアントはデータをサーバシステムに渡し、サーバはデータを受け取って結果をクライアントにフィードバックします。 5 | 6 | ## links 7 | * [目次]() 8 | * 前へ: [ファイルのアップロードの処理](<04.5.md>) 9 | * 次へ: [データベースへのアクセス](<05.0.md>) 10 | -------------------------------------------------------------------------------- /ebook/12.5.md: -------------------------------------------------------------------------------- 1 | # 12.5 小结 2 | 本章讨论了如何部署和维护我们开发的Web应用相关的一些话题。这些内容非常重要,要创建一个能够基于最小维护平滑运行的应用,必须考虑这些问题。 3 | 4 | 具体而言,本章讨论的内容包括: 5 | 6 | - 创建一个强健的日志系统,可以在出现问题时记录错误并且通知系统管理员 7 | - 处理运行时可能出现的错误,包括记录日志,并如何友好的显示给用户系统出现了问题 8 | - 处理404错误,告诉用户请求的页面找不到 9 | - 将应用部署到一个生产环境中(包括如何部署更新) 10 | - 如何让部署的应用程序具有高可用 11 | - 备份和恢复文件以及数据库 12 | 13 | 读完本章内容后,对于从头开始开发一个Web应用需要考虑那些问题,你应该已经有了全面的了解。本章内容将有助于你在实际环境中管理前面各章介绍开发的代码。 14 | 15 | ## links 16 | * [目录]() 17 | * 上一章: [备份和恢复](<12.4.md>) 18 | * 下一节: [如何设计一个Web框架](<13.0.md>) -------------------------------------------------------------------------------- /ja/ebook/06.5.md: -------------------------------------------------------------------------------- 1 | # 6.5 まとめ 2 | この章ではsession/cookieとは何かを、また両者の関係について勉強しました。しかし現在Goのオフィシャルパッケージではsessionがサポートされていません。そのため、sessionマネージャを設計しました。sessionの作成から破棄に至る全体の過程を実装し、Providerのインターフェースを定義することによって、各バックエンドのsessionストレージをサポートできるようにしました。第三節ではメモリストレージによってどのようにsessionの管理を実装するのかご紹介しました。第四節ではsessionハイジャックの過程と、どのようにsessionハイジャックを防止するのかを解説しました。第一章の解説を通して、読者の皆様方にはsessionの実行原理とどのように実現されるか、またどのように安全にsessionを使用するかについて理解いただけるよう望んています。 3 | ## links 4 | * [目次]() 5 | * 前へ: [sessionストレージ](<06.4.md>) 6 | * 次へ: [テキスト処理](<07.0.md>) 7 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/range_and_close_channel/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to close and interate through a channel 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | ) 8 | 9 | func fibonacci(n int, c chan int) { 10 | x, y := 1, 1 11 | for i := 0; i < n; i++ { 12 | c <- x 13 | x, y = y, x+y 14 | } 15 | close(c) 16 | } 17 | 18 | func main() { 19 | c := make(chan int, 10) 20 | go fibonacci(cap(c), c) 21 | for i := range c { 22 | fmt.Println(i) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /en/eBook/03.5.md: -------------------------------------------------------------------------------- 1 | # 3.5 Summary 2 | 3 | In this chapter, we introduced HTTP, DNS resolution flow and how to build a simple web server. Then we talked about how Go implements web servers for us by looking at the source code of the `net/http` package. 4 | 5 | I hope that you now know much more about web development, and you should see that it's quite easy and flexible to build a web application in Go. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous section: [Get into http package](03.4.md) 11 | - Next chapter: [User form](04.0.md) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/timeout/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to create and use a timeout 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | 11 | func main() { 12 | c := make(chan int) 13 | o := make(chan bool) 14 | go func() { 15 | for { 16 | select { 17 | case v := <-c: 18 | fmt.Println(v) 19 | case <-time.After(5 * time.Second): 20 | fmt.Println("timeout") 21 | o <- true 22 | break 23 | } 24 | } 25 | }() 26 | <-o 27 | } 28 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/variadic_functions/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Shows how to return multiple values from a function 3 | package main 4 | 5 | import "fmt" 6 | 7 | // return results of A + B and A * B 8 | func SumAndProduct(A, B int) (int, int) { 9 | return A + B, A * B 10 | } 11 | 12 | func main() { 13 | x := 3 14 | y := 4 15 | 16 | xPLUSy, xTIMESy := SumAndProduct(x, y) 17 | 18 | fmt.Printf("%d + %d = %d\n", x, y, xPLUSy) 19 | fmt.Printf("%d * %d = %d\n", x, y, xTIMESy) 20 | } 21 | -------------------------------------------------------------------------------- /en/eBook/04.6.md: -------------------------------------------------------------------------------- 1 | # 4.6 Summary 2 | 3 | In this chapter, we mainly learned how to process form data in Go through several examples like logging in users and uploading files. We also emphasized that verifying user data is extremely important for website security, and we used one section to talk about how to filter data with regular expressions. 4 | 5 | I hope that you now know more about the communication process between client and server. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous section: [File upload](04.5.md) 11 | - Next chapter: [Database](05.0.md) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.3/readme.md: -------------------------------------------------------------------------------- 1 | ## Set up for `ch.5.3` 2 | 3 | - Step 1) Download and install sqlite 3. 4 | - Step 2) Run `sqlite3 foo.db` to create a databased called `foo`. 5 | - Step 3) Create the `userinfo` table in sqlite using `schema.sql`. 6 | 7 | Read and run sql statements 8 | 9 | sqlite> .read schema.sql 10 | 11 | Show tables 12 | 13 | sqlite> .tables 14 | userinfo 15 | 16 | 17 | - Step 4) Exit sqlite. 18 | 19 | sqlite> .exit 20 | 21 | - Step 5) Run `go get` to download and install remote packages. 22 | - Step 6) Run the program with `go run main.go` 23 | 24 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.5/readme.md: -------------------------------------------------------------------------------- 1 | ## Set up for `ch.5.5` 2 | 3 | - Step 1) Download and install sqlite 3. 4 | - Step 2) Run `sqlite3 foo.db` to create a databased called `foo`. 5 | - Step 3) Create the tables found in `schema.sql` in sqlite. 6 | 7 | Read and run sql statements 8 | 9 | sqlite> .read schema.sql 10 | 11 | Show tables 12 | 13 | sqlite> .tables 14 | userinfo 15 | userdetail 16 | 17 | - Step 4) Exit sqlite. 18 | 19 | sqlite> .exit 20 | 21 | - Step 5) Run `go get` to download and install remote packages. 22 | - Step 6) Run the program with `go run main.go` 23 | 24 | -------------------------------------------------------------------------------- /en/eBook/03.0.md: -------------------------------------------------------------------------------- 1 | #3 Web foundation 2 | 3 | The reason you are reading this book is that you want to learn to build web applications in Go. As i've said before, Go provides many powerful packages like `http`. These packages can help you a lot when trying to build web applications. I'll teach you everything you need to know in the following chapters, and we'll talk about some concepts of the web and how to run web applications in Go in this chapter. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous chapter: [Chapter 2 Summary](02.8.md) 9 | - Next section: [Web working principles](03.1.md) 10 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/unbuffered_channel/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to create and use a unbuffered channel 3 | package main 4 | 5 | import "fmt" 6 | 7 | func sum(a []int, c chan int) { 8 | total := 0 9 | for _, v := range a { 10 | total += v 11 | } 12 | c <- total // send total to c 13 | } 14 | 15 | func main() { 16 | a := []int{7, 2, 8, -9, 4, 0} 17 | 18 | c := make(chan int) 19 | go sum(a[:len(a)/2], c) 20 | go sum(a[len(a)/2:], c) 21 | x, y := <-c, <-c // receive from c 22 | 23 | fmt.Println(x, y, x+y) 24 | } 25 | -------------------------------------------------------------------------------- /ja/ebook/13.6.md: -------------------------------------------------------------------------------- 1 | # 13.6 まとめ 2 | この章ではどのように基礎的なGo言語のフレームワークを実装するかについてご紹介しました。フレームワークにはルーティング設計が含まれます。Goのビルトインのhttpパッケージにあるルーティングにはいくつか足りない部分があるため、我々は動的なルーティング規則を設計し、その後MVCモデルにおけるController設計をご紹介しました。controllerはRESTを実装しており、主な考え方はtornadeフレームワークからきています。次にも出るのlayoutおよびテンプレートの自動化技術を実装しました。主に採用したのはGoのビルトインのモデルエンジンです。最後に補足的なログ、設定といった情報の設計をご紹介しました。これらの設計を通して基礎的なフレームワークbeegoを実装しました。現在このフレームワークはすでにgithub上でオープンソースになっています。最後に我々はbeegoを通じてブログシステムの実装を行いました。この実例コードを通してどのように快速にホームページを開発するのかが見渡せたのではないかと思います。 3 | 4 | ## links 5 | * [目次]() 6 | * 前へ: [ブログの追加/削除/修正の実装](<13.5.md>) 7 | * 次へ: [Webフレームワークの拡張](<14.0.md>) 8 | -------------------------------------------------------------------------------- /ja/ebook/01.5.md: -------------------------------------------------------------------------------- 1 | # 1.5 まとめ 2 | 3 | この章では主にどのようにしてGoをインストールするかについてご紹介しました。Goは3つの種類のインストール方法があります:ソースコードインストール、標準パッケージインストール、サードパーティツールによるインストールです。インストール後開発環境を整え、ローカルの`$GOPATH`を設定します。`$GOPATH`設定を通じて読者はプロジェクトを作成することができます。次にどのようにプロジェクトをコンパイルするのか説明しました。アプリケーションのインストールといった問題はたくさんのGoコマンドを使用する必要があります。そのため、Goで日常的に用いられるコマンドツールについてもご説明しました。コンパイル、インストール、整形、テストなどのコマンドです。最後にGoの開発ツールについてご紹介しました。現在多くのGoの開発ツールには:LiteIDE、sublime、VIM、Emacs、Eclipse、Ideaといったツールがあります。読者は自分が一番慣れ親しんだツールを設定することができます。便利なツールで素早くGoアプリケーションを開発できるよう願っています。 4 | 5 | ## links 6 | * [目次]() 7 | * 前へ: [Goの開発ツール](<01.4.md>) 8 | * 次へ: [Go言語の基礎](<02.0.md>) 9 | -------------------------------------------------------------------------------- /ja/ebook/08.5.md: -------------------------------------------------------------------------------- 1 | # 8.5 まとめ 2 | この章では現在流行しているいくつかの主なネットワークアプリケーションの開発方法についてご紹介しました。第一節ではネットワークプログラミングの基礎をご紹介しました。Socketプログラミングです。なぜなら現在ネットワークはクラウドの方向に急速に進化しています。この技術で展開されるsocket知識の基礎は開発者としてマスターしておかなければなりません。第二節では現在流行しつつあるHTML5の重要な特徴であるWebSocketについてご紹介しました。これを使うとサーバは主導的に情報をpushできるようになります。昔のajaxポーリングパターンの簡略化も述べました。第三節ではRESTプログラミングパターンをご紹介しました。これらのパターンは特にネットワークアプリケーションAPIの開発に適しています。上の四種類の開発方法において、Goはすでに良いサポートを提供しています。netパッケージおよびそのサブパッケージはいずれもネットワークプログラミングのツールの在り処を含んでいます。もしより詳しく関連する実装の詳細に足を踏み入れるのであれば、このパッケージのソースコードを試しに読んでみてください。 3 | ## links 4 | * [目次]() 5 | * 前へ: [RPC](<08.4.md>) 6 | * 次へ: [セキュリティと暗号化](<09.0.md>) 7 | -------------------------------------------------------------------------------- /ebook/14.0.md: -------------------------------------------------------------------------------- 1 | # 14 扩展Web框架 2 | 第十三章介绍了如何开发一个Web框架,通过介绍MVC、路由、日志处理、配置处理完成了一个基本的框架系统,但是一个好的框架需要一些方便的辅助工具来快速的开发Web,那么我们这一章将就如何提供一些快速开发Web的工具进行介绍,第一小节介绍如何处理静态文件,如何利用现有的twitter开源的bootstrap进行快速的开发美观的站点,第二小节介绍如何利用前面介绍的session来进行用户登录处理,第三小节介绍如何方便的输出表单、这些表单如何进行数据验证,如何快速的结合model进行数据的增删改操作,第四小节介绍如何进行一些用户认证,包括http basic认证、http digest认证,第五小节介绍如何利用前面介绍的i18n支持多语言的应用开发。 3 | 4 | 通过本章的扩展,beego框架将具有快速开发Web的特性,最后我们将讲解如何利用这些扩展的特性扩展开发第十三章开发的博客系统,通过开发一个完整、美观的博客系统让读者了解beego开发带给你的快速。 5 | 6 | ## 目录 7 | ![](images/navi14.png?raw=true) 8 | 9 | ## links 10 | * [目录]() 11 | * 上一章: [第十三章总结](<13.6.md>) 12 | * 下一节: [静态文件支持](<14.1.md>) -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.7/select_channel/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.7 from "Build Web Application with Golang" 2 | // Purpose: Shows how to use `select` 3 | package main 4 | 5 | import "fmt" 6 | 7 | func fibonacci(c, quit chan int) { 8 | x, y := 1, 1 9 | for { 10 | select { 11 | case c <- x: 12 | x, y = y, x+y 13 | case <-quit: 14 | fmt.Println("quit") 15 | return 16 | } 17 | } 18 | } 19 | 20 | func main() { 21 | c := make(chan int) 22 | quit := make(chan int) 23 | go func() { 24 | for i := 0; i < 10; i++ { 25 | fmt.Println(<-c) 26 | } 27 | quit <- 0 28 | }() 29 | fibonacci(c, quit) 30 | } 31 | -------------------------------------------------------------------------------- /ja/ebook/05.7.md: -------------------------------------------------------------------------------- 1 | # 5.7 まとめ 2 | この章ではGoがどのようにdatabase/sqlインターフェースを設計するのかご説明しました。その後、サードパーティによるリレーショナルデータベースドライバの使用をご紹介しました。次にbeedbというリレーショナルデータベースに基づくORMライブラリがどのようにしてデータベースに対して簡単な操作を行うかご説明しました。最後にNOSQLのいくつかの知識をご紹介しました。現在GoのNOSQLに対するサポートはなかなかよくできています。Goは21世紀のC言語ですから、21世紀のデータベースに対するサポートも非常によくできています。 3 | 4 | この一章の学習を通じて、いろいろなデータベースをどのように操作するか学んできました。Webの中でも重要なデータの保存に関する問題が解決したので、みなさんのdatabase/sqlの設計思想により一歩進んだ理解が深まることを願っています。 5 | 6 | >[Go database/sql tutorial](http://go-database-sql.org/)ではよく使われる例と詳細な説明を提供しています。 7 | 8 | ## links 9 | * [目次]() 10 | * 前へ: [NOSQLデータベースの操作](<05.6.md>) 11 | * 次へ: [sessionとデータの保存](<06.0.md>) 12 | -------------------------------------------------------------------------------- /ebook/14.7.md: -------------------------------------------------------------------------------- 1 | # 14.7 小结 2 | 这一章主要阐述了如何基于beego框架进行扩展,这包括静态文件的支持,静态文件主要讲述了如何利用beego进行快速的网站开发,利用bootstrap搭建漂亮的站点;第二小结讲解了如何在beego中集成sessionManager,方便用户在利用beego的时候快速的使用session;第三小结介绍了表单和验证,基于Go语言的struct的定义使得我们在开发Web的过程中从重复的工作中解放出来,而且加入了验证之后可以尽量做到数据安全,第四小结介绍了用户认证,用户认证主要有三方面的需求,http basic和http digest认证,第三方认证,自定义认证,通过代码演示了如何利用现有的第三方包集成到beego应用中来实现这些认证;第五小节介绍了多语言的支持,beego中集成了go-i18n这个多语言包,用户可以很方便的利用该库开发多语言的Web应用;第六小节介绍了如何集成Go的pprof包,pprof包是用于性能调试的工具,通过对beego的改造之后集成了pprof包,使得用户可以利用pprof测试基于beego开发的应用,通过这六个小节的介绍我们扩展出来了一个比较强壮的beego框架,这个框架足以应付目前大多数的Web应用,用户可以继续发挥自己的想象力去扩展,我这里只是简单的介绍了我能想的到的几个比较重要的扩展。 3 | 4 | ## links 5 | * [目录]() 6 | * 上一节: [pprof支持](<14.6.md>) -------------------------------------------------------------------------------- /ja/ebook/09.7.md: -------------------------------------------------------------------------------- 1 | # 9.7 まとめ 2 | この章ではCSRF攻撃、XSS攻撃、SQLインジェクション攻撃といったWebアプリケーションの典型的な攻撃手法をご紹介しました。これらはどれもアプリケーションがユーザの入力に対して良いフィルタリングを起こさなかったことによるものです。そのため、攻撃の方法をご紹介する以外に、これらの攻撃の発生を防止する方法としてどのようにして有効にデータをフィルタリングするかについてもご紹介しました。また、日増しに発生する重大なパスワード漏洩事件に対し、Webアプリケーションを設計する上で採用可能な暗号化ソリューションについて基礎から専門的なものまでご紹介しました。最後に慎重に扱うべきデータに対する暗号化/復元をご紹介しました。Go言語では三種類の双方向暗号化アルゴリズムを提供しています:base64、aesとdesの実装です。 3 | 4 | この章を書いた目的は読者の意識でセキュリティの概念を強化して欲しいと思ったからです。Webアプリケーションを書く時はぜひご注意していただき、我々が書くWebアプリケーションをハッカー達の攻撃から遠ざけるようにしてください。これらのパッケージを十分に利用することで、安全なWebアプリケーションを作ることができます。 5 | 6 | ## links 7 | * [目次]() 8 | * 前へ: [データの暗号化/復元](<09.6.md>) 9 | * 次へ: [国際化とローカライズ](<10.0.md>) 10 | -------------------------------------------------------------------------------- /ja/ebook/11.4.md: -------------------------------------------------------------------------------- 1 | # 11.4 まとめ 2 | この章では3つの節に分けてGo言語においてどのようにエラーを処理するか、どのようにエラー処理を設計するかをご紹介しました。第二節ではどのようにしてGDBを使ってプログラムをデバッグするかご紹介しました。GDBを使うことで我々は簡単にステップ実行、変数の表示、変数の修正、実行過程の出力等を行うことができます。最後にどのようにしてGo言語がはじめから持っている軽量なフレームワーク`testing`を利用してユニットテストと耐久テストを書くかについてご紹介しました。`go test`を使用することで便利にこれらのテストを行うことができ、将来のコードがアップグレードされ、修正された後でも簡単に回帰テストを行うことができます。この章はあなたがプログラムのロジックを書くことに対して何の助けにもならなかったかもしれません。しかし、あなたが書いたプログラムコードの質を高く保つには非常に重要です。なぜならよくできたWebアプリケーションは必ずよくできたエラー処理メカニズム(エラーの表示がユーザフレンドリーで拡張性がある)を持っているからです。ユーザフレンドリーなユニットテストと耐久テストは実運用が開始された後のコードが良い性能を保ち、予定通り実行されることを保証してくれます。 3 | 4 | ## links 5 | * [目次]() 6 | * 前へ: [Goでどのようにテストを書くか](<11.3.md>) 7 | * 次へ: [デプロイとメンテナンス](<12.0.md>) 8 | -------------------------------------------------------------------------------- /ebook/02.0.md: -------------------------------------------------------------------------------- 1 | # 2 Go语言基础 2 | 3 | Go是一门类似C的编译型语言,但是它的编译速度非常快。这门语言的关键字总共也就二十五个,比英文字母还少一个,这对于我们的学习来说就简单了很多。先让我们看一眼这些关键字都长什么样: 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | 在接下来的这一章中,我将带领你去学习这门语言的基础。通过每一小节的介绍,你将发现,Go的世界是那么地简洁,设计是如此地美妙,编写Go将会是一件愉快的事情。等回过头来,你就会发现这二十五个关键字是多么地亲切。 12 | 13 | ## 目录 14 | ![](images/navi2.png?raw=true) 15 | 16 | ## links 17 | * [目录]() 18 | * 上一章: [第一章总结](<01.5.md>) 19 | * 下一节: [你好,Go](<02.1.md>) 20 | -------------------------------------------------------------------------------- /ebook/05.0.md: -------------------------------------------------------------------------------- 1 | # 5 访问数据库 2 | 对许多Web应用程序而言,数据库都是其核心所在。数据库几乎可以用来存储你想查询和修改的任何信息,比如用户信息、产品目录或者新闻列表等。 3 | 4 | Go没有内置的驱动支持任何的数据库,但是Go定义了database/sql接口,用户可以基于驱动接口开发相应数据库的驱动,5.1小节里面介绍Go设计的一些驱动,介绍Go是如何设计数据库驱动接口的。5.2至5.4小节介绍目前使用的比较多的一些关系型数据驱动以及如何使用,5.5小节介绍我自己开发一个ORM库,基于database/sql标准接口开发的,可以兼容几乎所有支持database/sql的数据库驱动,可以方便的使用Go style来进行数据库操作。 5 | 6 | 目前NOSQL已经成为Web开发的一个潮流,很多应用采用了NOSQL作为数据库,而不是以前的缓存,5.6小节将介绍MongoDB和Redis两种NOSQL数据库。 7 | 8 | >[Go database/sql tutorial](http://go-database-sql.org/) 里提供了惯用的范例及详细的说明。 9 | 10 | ## 目录 11 | ![](images/navi5.png?raw=true) 12 | 13 | ## links 14 | * [目录]() 15 | * 上一章: [第四章总结](<04.6.md>) 16 | * 下一节: [database/sql接口](<05.1.md>) 17 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/basic_functions/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Creating a basic function 3 | package main 4 | 5 | import "fmt" 6 | 7 | // return greater value between a and b 8 | func max(a, b int) int { 9 | if a > b { 10 | return a 11 | } 12 | return b 13 | } 14 | 15 | func main() { 16 | x := 3 17 | y := 4 18 | z := 5 19 | 20 | max_xy := max(x, y) // call function max(x, y) 21 | max_xz := max(x, z) // call function max(x, z) 22 | 23 | fmt.Printf("max(%d, %d) = %d\n", x, y, max_xy) 24 | fmt.Printf("max(%d, %d) = %d\n", x, z, max_xz) 25 | fmt.Printf("max(%d, %d) = %d\n", y, z, max(y, z)) // call function here 26 | } 27 | -------------------------------------------------------------------------------- /en/eBook/07.7.md: -------------------------------------------------------------------------------- 1 | # 7.7 Summary 2 | 3 | In this chapter, we introduced some text processing tools like XML, JSON, Regexp and we also talked about templates. XML and JSON are data exchange tools. You can represent almost any kind of information using these two formats. Regexp is a powerful tool for searching, replacing and cutting text content. With templates, you can easily combine dynamic data with static files. These tools are all useful when developping web applications. I hope that you now have a better understanding of processing and showing content using Go. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [Strings](07.6.md) 9 | - Next chapter: [Web services](08.0.md) 10 | -------------------------------------------------------------------------------- /ja/ebook/12.0.md: -------------------------------------------------------------------------------- 1 | # 12 デプロイとメンテナンス 2 | 現在までのところ、我々はどのようにプログラムを開発するかご紹介しました。プログラムのデバッグとテストには開発の最後の10%は90%の時間を必要とすると言われます。ですから、この章では最後の10%の部分を強調して、信用と使用に足る優秀なアプリケーションになるよう細部を考慮する必要があります。上の10%はこれらの細部を指しています。 3 | 4 | この章では4つの節によってこれらの細部の処理をご紹介します。第一節ではサーバでプログラムが生成するログをどのように記録するかご紹介します。第二節ではエラーが発生した時に我々のプログラムがどのように処理されるかと、ユーザのアクセスに与える影響をなるべく少なくするにはどうすべきかご紹介します。第三節ではGoの独立したプログラムをどのようにデプロイするかご紹介します。現在GoプログラムはまだCのようにdaemonを書くことができません。ではこれらのプロセスとプログラムのバックエンドをどのように実行すべきでしょうか?第四節ではアプリケーションデータのバックアップとリストアをご紹介します。アプリケーションが壊れた状況でなるべくデータの完全性を保証します。 5 | ## 目次 6 | ![](images/navi12.png?raw=true) 7 | 8 | ## links 9 | * [目次]() 10 | * 前へ: [第十一章まとめ](<11.4.md>) 11 | * 次へ: [アプリケーションログ](<12.1.md>) 12 | -------------------------------------------------------------------------------- /ebook/13.0.md: -------------------------------------------------------------------------------- 1 | # 13 如何设计一个Web框架 2 | 前面十二章介绍了如何通过Go来开发Web应用,介绍了很多基础知识、开发工具和开发技巧,那么我们这一章通过这些知识来实现一个简易的Web框架。通过Go语言来实现一个完整的框架设计,这框架中主要内容有第一小节介绍的Web框架的结构规划,例如采用MVC模式来进行开发,程序的执行流程设计等内容;第二小节介绍框架的第一个功能:路由,如何让访问的URL映射到相应的处理逻辑;第三小节介绍处理逻辑,如何设计一个公共的controller,对象继承之后处理函数中如何处理response和request;第四小节介绍如何框架的一些辅助功能,例如日志处理、配置信息等;第五小节介绍如何基于Web框架实现一个博客,包括博文的发表、修改、删除、显示列表等操作。 3 | 4 | 通过这么一个完整的项目例子,我期望能够让读者了解如何开发Web应用,如何搭建自己的目录结构,如何实现路由,如何实现MVC模式等各方面的开发内容。在框架盛行的今天,MVC也不再是神话。经常听到很多程序员讨论哪个框架好,哪个框架不好, 其实框架只是工具,没有好与不好,只有适合与不适合,适合自己的就是最好的,所以教会大家自己动手写框架,那么不同的需求都可以用自己的思路去实现。 5 | 6 | ## 目录 7 | ![](images/navi13.png?raw=true) 8 | 9 | ## links 10 | * [目录]() 11 | * 上一章: [第十二章总结](<12.5.md>) 12 | * 下一节: [项目规划](<13.1.md>) -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.5/embedded_method/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | 4 | type Human struct { 5 | name string 6 | age int 7 | phone string 8 | } 9 | 10 | type Student struct { 11 | Human // anonymous field 12 | school string 13 | } 14 | 15 | type Employee struct { 16 | Human 17 | company string 18 | } 19 | 20 | // define a method in Human 21 | func (h *Human) SayHi() { 22 | fmt.Printf("Hi, I am %s you can call me on %s\n", h.name, h.phone) 23 | } 24 | 25 | func main() { 26 | mark := Student{Human{"Mark", 25, "222-222-YYYY"}, "MIT"} 27 | sam := Employee{Human{"Sam", 45, "111-888-XXXX"}, "Golang Inc"} 28 | 29 | mark.SayHi() 30 | sam.SayHi() 31 | } 32 | -------------------------------------------------------------------------------- /ebook/01.0.md: -------------------------------------------------------------------------------- 1 | # 1 GO环境配置 2 | 3 | 欢迎来到Go的世界,让我们开始探索吧! 4 | 5 | Go是一种新的语言,一种并发的、带垃圾回收的、快速编译的语言。它具有以下特点: 6 | 7 | - 它可以在一台计算机上用几秒钟的时间编译一个大型的Go程序。 8 | - Go为软件构造提供了一种模型,它使依赖分析更加容易,且避免了大部分C风格include文件与库的开头。 9 | - Go是静态类型的语言,它的类型系统没有层级。因此用户不需要在定义类型之间的关系上花费时间,这样感觉起来比典型的面向对象语言更轻量级。 10 | - Go完全是垃圾回收型的语言,并为并发执行与通信提供了基本的支持。 11 | - 按照其设计,Go打算为多核机器上系统软件的构造提供一种方法。 12 | 13 | Go是一种编译型语言,它结合了解释型语言的游刃有余,动态类型语言的开发效率,以及静态类型的安全性。它也打算成为现代的,支持网络与多核计算的语言。要满足这些目标,需要解决一些语言上的问题:一个富有表达能力但轻量级的类型系统,并发与垃圾回收机制,严格的依赖规范等等。这些无法通过库或工具解决好,因此Go也就应运而生了。 14 | 15 | 在本章中,我们将讲述Go的安装方法,以及如何配置项目信息。 16 | 17 | ## 目录 18 | 19 | ![](images/navi1.png?raw=true) 20 | 21 | ## links 22 | * [目录]() 23 | * 下一节: [Go安装](<01.1.md>) 24 | -------------------------------------------------------------------------------- /ebook/ref.md: -------------------------------------------------------------------------------- 1 | # 附录A 参考资料 2 | 3 | 这本书的内容基本上是我学习Go过程以及以前从事Web开发过程中的一些经验总结,里面部分内容参考了很多站点的内容,感谢这些站点的内容让我能够总结出来这本书,参考资料如下: 4 | 5 | 1. [golang blog](http://blog.golang.org) 6 | 2. [Russ Cox blog](http://research.swtch.com/) 7 | 3. [go book](http://go-book.appsp0t.com/) 8 | 4. [golangtutorials](http://golangtutorials.blogspot.com) 9 | 5. [轩脉刃de刀光剑影](http://www.cnblogs.com/yjf512/) 10 | 6. [Go 官网文档](http://golang.org/doc/) 11 | 7. [Network programming with Go](http://jan.newmarch.name/go/) 12 | 8. [setup-the-rails-application-for-internationalization](http://guides.rubyonrails.org/i18n.html#setup-the-rails-application-for-internationalization) 13 | 9. [The Cross-Site Scripting (XSS) FAQ](http://www.cgisecurity.com/xss-faq.html) 14 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.3.4/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 3.4 from "Build Web Application with Golang" 2 | // Purpose: Shows how to create a handler for `http.ListenAndServe()` 3 | // Run `go run main.go` then access `http://localhost:9090` 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "net/http" 9 | ) 10 | 11 | type MyMux struct { 12 | } 13 | 14 | func (p *MyMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { 15 | if r.URL.Path == "/" { 16 | sayhelloName(w, r) 17 | return 18 | } 19 | http.NotFound(w, r) 20 | return 21 | } 22 | 23 | func sayhelloName(w http.ResponseWriter, r *http.Request) { 24 | fmt.Fprintf(w, "Hello myroute!") 25 | } 26 | 27 | func main() { 28 | mux := &MyMux{} 29 | http.ListenAndServe(":9090", mux) 30 | } 31 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.4/embedded_structs_with_name_conflict/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.4 from "Build Web Application with Golang" 2 | // Purpose: Shows a name conflict with a embedded field 3 | package main 4 | 5 | import "fmt" 6 | 7 | type Human struct { 8 | name string 9 | age int 10 | phone string // Human has phone field 11 | } 12 | 13 | type Employee struct { 14 | Human // embedded field Human 15 | speciality string 16 | phone string // phone in employee 17 | } 18 | 19 | func main() { 20 | Bob := Employee{Human{"Bob", 34, "777-444-XXXX"}, "Designer", "333-222"} 21 | fmt.Println("Bob's work phone is:", Bob.phone) 22 | // access phone field in Human 23 | fmt.Println("Bob's personal phone is:", Bob.Human.phone) 24 | } 25 | -------------------------------------------------------------------------------- /ebook/07.0.md: -------------------------------------------------------------------------------- 1 | # 7 文本处理 2 | Web开发中对于文本处理是非常重要的一部分,我们往往需要对输出或者输入的内容进行处理,这里的文本包括字符串、数字、Json、XMl等等。Go语言作为一门高性能的语言,对这些文本的处理都有官方的标准库来支持。而且在你使用中你会发现Go标准库的一些设计相当的巧妙,而且对于使用者来说也很方便就能处理这些文本。本章我们将通过四个小节的介绍,让用户对Go语言处理文本有一个很好的认识。 3 | 4 | XML是目前很多标准接口的交互语言,很多时候和一些Java编写的webserver进行交互都是基于XML标准进行交互,7.1小节将介绍如何处理XML文本,我们使用XML之后发现它太复杂了,现在很多互联网企业对外的API大多数采用了JSON格式,这种格式描述简单,但是又能很好的表达意思,7.2小节我们将讲述如何来处理这样的JSON格式数据。正则是一个让人又爱又恨的工具,它处理文本的能力非常强大,我们在前面表单验证里面已经有所领略它的强大,7.3小节将详细的更深入的讲解如何利用好Go的正则。Web开发中一个很重要的部分就是MVC分离,在Go语言的Web开发中V有一个专门的包来支持`template`,7.4小节将详细的讲解如何使用模版来进行输出内容。7.5小节将详细介绍如何进行文件和文件夹的操作。7.6小结介绍了字符串的相关操作。 5 | 6 | ## 目录 7 | ![](images/navi7.png?raw=true) 8 | 9 | ## links 10 | * [目录]() 11 | * 上一章: [第六章总结](<06.5.md>) 12 | * 下一节: [XML处理](<07.1.md>) 13 | -------------------------------------------------------------------------------- /ja/ebook/02.0.md: -------------------------------------------------------------------------------- 1 | # 2 Go言語の基礎 2 | 3 | GoはCに似たコンパイラ型言語です。ですが、このコンパイル速度は非常に速く、この言語のキーワードもたったの25個です。英文よりも少し少なく勉強するにはかなり簡単です。まずはこれらのキーワードがどのようなものか見てみることにしましょう: 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | この章では、この言語の基礎勉強にあなたを連れていきます。各章の紹介を通じて、Goの世界がどれほどまでに簡潔で絶妙にデザインされているかお分かりいただけるはずです。Goを書くことはとても楽しいことです。後から振り返ると、この25個のキーワードがどれだけフレンドリーか理解するはずです。 12 | 13 | ## 目次 14 | ![](images/navi2.png?raw=true) 15 | 16 | ## links 17 | * [目次]() 18 | * 前へ: [第一章まとめ](<01.5.md>) 19 | * 次へ: [こんにちは、Go](<02.1.md>) 20 | -------------------------------------------------------------------------------- /en/eBook/ref.md: -------------------------------------------------------------------------------- 1 | # Appendix A References 2 | 3 | This book is a summary of my Go experience, some content are from other gophers' either blog or sites. Thanks them! 4 | 5 | 1. [golang blog](http://blog.golang.org) 6 | 2. [Russ Cox blog](http://research.swtch.com/) 7 | 3. [go book](http://go-book.appsp0t.com/) 8 | 4. [golangtutorials](http://golangtutorials.blogspot.com) 9 | 5. [轩脉刃de刀光剑影](http://www.cnblogs.com/yjf512/) 10 | 6. [Go Programming Language](http://golang.org/doc/) 11 | 7. [Network programming with Go](http://jan.newmarch.name/go/) 12 | 8. [setup-the-rails-application-for-internationalization](http://guides.rubyonrails.org/i18n.html#setup-the-rails-application-for-internationalization) 13 | 9. [The Cross-Site Scripting (XSS) FAQ](http://www.cgisecurity.com/xss-faq.html) -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/panic_and_recover/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Showing how to use `panic()` and `recover()` 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | ) 9 | 10 | var user = os.Getenv("USER") 11 | 12 | func check_user() { 13 | if user == "" { 14 | panic("no value for $USER") 15 | } 16 | fmt.Println("Environment Variable `USER` =", user) 17 | } 18 | func throwsPanic(f func()) (b bool) { 19 | defer func() { 20 | if x := recover(); x != nil { 21 | fmt.Println("Panic message =", x); 22 | b = true 23 | } 24 | }() 25 | f() // if f causes panic, it will recover 26 | return 27 | } 28 | func main(){ 29 | didPanic := throwsPanic(check_user) 30 | fmt.Println("didPanic =", didPanic) 31 | } 32 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.3/index.gtpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Cross Site Scripting Attack Test

5 | {{if .}} 6 | Previous User Input:
7 | 8 |
{{.}}
9 | {{end}} 10 |
11 | 15 |
16 | 20 |
21 | 22 |
23 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ja/ebook/12.5.md: -------------------------------------------------------------------------------- 1 | # 12.5 まとめ 2 | この章ではどのようにして我々の開発したWebアプリケーションのデプロイとメンテナンスを行うかについていくつかのトピックを討論しました。これらの内容は非常に重要で、メンテナンスを最小化し、アプリケーションの円滑な運用を行うためにはかならずこれらの問題を考慮する必要があります。 3 | 4 | この章で討論した内容は具体的には: 5 | 6 | - 強靭なログシステムを作成し、問題が発生した際にエラーを記録してシステム管理者に通知を行うことができます。 7 | - 実行時に発生しうるエラーの処理。ログへの記録を含み、システムが発生させた問題についてユーザフレンドリーな表示をどのようにユーザに行うか。 8 | - 404エラーの処理。ユーザがリクエストしたページが見つからないことを示します。 9 | - アプリケーションを生産環境の中にデプロイする。(どのようにしてデプロイを更新するかを含みます) 10 | - デプロイしたアプリケーションの可用性を高めるにはどうすればよいか。 11 | - ファイル及びデータベースのバックアップとリストア 12 | 13 | この章を読み終わると、スクラッチで一つのWebアプリケーションを開発するのに対してどのような問題を考慮しなければならないのか、あなたは既に全面的な理解が得られたはずです。この章の内容は実際の環境において前の各章でご紹介した開発コードを管理するのに役立ちます。 14 | 15 | ## links 16 | * [目次]() 17 | * 前へ: [バックアップとリストア](<12.4.md>) 18 | * 次へ: [どのようにしてWebフレームワークを設計するか](<13.0.md>) 19 | -------------------------------------------------------------------------------- /ja/ebook/ref.md: -------------------------------------------------------------------------------- 1 | # 付録A 参考資料 2 | 3 | この本の内容は基本的に、私のGoの学習過程と以前携わったWeb開発の仕事から得られた経験によりまとめられています。いくつかの内容はたくさんのサイトの内容を参考にしています。この本をまとめてこられたのもこれらサイトのおかげで、大変感謝しています。参考資料は以下のとおりです: 4 | 5 | 1. [golang blog](http://blog.golang.org) 6 | 2. [Russ Cox blog](http://research.swtch.com/) 7 | 3. [go book](http://go-book.appsp0t.com/) 8 | 4. [golangtutorials](http://golangtutorials.blogspot.com) 9 | 5. [轩脉刃de刀光剑影](http://www.cnblogs.com/yjf512/) 10 | 6. [Go オフィシャルドキュメント](http://golang.org/doc/) 11 | 7. [Network programming with Go](http://jan.newmarch.name/go/) 12 | 8. [setup-the-rails-application-for-internationalization](http://guides.rubyonrails.org/i18n.html#setup-the-rails-application-for-internationalization) 13 | 9. [The Cross-Site Scripting (XSS) FAQ](http://www.cgisecurity.com/xss-faq.html) 14 | -------------------------------------------------------------------------------- /ebook/06.0.md: -------------------------------------------------------------------------------- 1 | # 6 session和数据存储 2 | Web开发中一个很重要的议题就是如何做好用户的整个浏览过程的控制,因为HTTP协议是无状态的,所以用户的每一次请求都是无状态的,我们不知道在整个Web操作过程中哪些连接与该用户有关,我们应该如何来解决这个问题呢?Web里面经典的解决方案是cookie和session,cookie机制是一种客户端机制,把用户数据保存在客户端,而session机制是一种服务器端的机制,服务器使用一种类似于散列表的结构来保存信息,每一个网站访客都会被分配给一个唯一的标志符,即sessionID,它的存放形式无非两种:要么经过url传递,要么保存在客户端的cookies里.当然,你也可以将Session保存到数据库里,这样会更安全,但效率方面会有所下降。 3 | 4 | 6.1小节里面讲介绍session机制和cookie机制的关系和区别,6.2讲解Go语言如何来实现session,里面讲实现一个简易的session管理器,6.3小节讲解如何防止session被劫持的情况,如何有效的保护session。我们知道session其实可以存储在任何地方,6.3小节里面实现的session是存储在内存中的,但是如果我们的应用进一步扩展了,要实现应用的session共享,那么我们可以把session存储在数据库中(memcache或者redis),6.4小节将详细的讲解如何实现这些功能。 5 | 6 | ## 目录 7 | ![](images/navi6.png?raw=true) 8 | 9 | ## links 10 | * [目录]() 11 | * 上一章: [第五章总结](<05.7.md>) 12 | * 下一节: [session和cookie](<06.1.md>) 13 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.5/method_overload/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Human struct { 6 | name string 7 | age int 8 | phone string 9 | } 10 | 11 | type Student struct { 12 | Human 13 | school string 14 | } 15 | 16 | type Employee struct { 17 | Human 18 | company string 19 | } 20 | 21 | func (h *Human) SayHi() { 22 | fmt.Printf("Hi, I am %s you can call me on %s\n", h.name, h.phone) 23 | } 24 | 25 | func (e *Employee) SayHi() { 26 | fmt.Printf("Hi, I am %s, I work at %s. Call me on %s\n", e.name, 27 | e.company, e.phone) //Yes you can split into 2 lines here. 28 | } 29 | 30 | func main() { 31 | mark := Student{Human{"Mark", 25, "222-222-YYYY"}, "MIT"} 32 | sam := Employee{Human{"Sam", 45, "111-888-XXXX"}, "Golang Inc"} 33 | 34 | mark.SayHi() 35 | sam.SayHi() 36 | } 37 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.5/attach_methods_to_struct/main.go: -------------------------------------------------------------------------------- 1 | // Example code from Chapter 2.5 2 | // Attach method to struct. 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "math" 8 | ) 9 | 10 | type Rectangle struct { 11 | width, height float64 12 | } 13 | 14 | type Circle struct { 15 | radius float64 16 | } 17 | 18 | func (r Rectangle) area() float64 { 19 | return r.width * r.height 20 | } 21 | 22 | func (c Circle) area() float64 { 23 | return c.radius * c.radius * math.Pi 24 | } 25 | 26 | func main() { 27 | r1 := Rectangle{12, 2} 28 | r2 := Rectangle{9, 4} 29 | c1 := Circle{10} 30 | c2 := Circle{25} 31 | 32 | fmt.Println("Area of r1 is: ", r1.area()) 33 | fmt.Println("Area of r2 is: ", r2.area()) 34 | fmt.Println("Area of c1 is: ", c1.area()) 35 | fmt.Println("Area of c2 is: ", c2.area()) 36 | } 37 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.6/reflection/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func show_interface_none() { 9 | fmt.Println("\nshow_interface_none()") 10 | var a interface{} 11 | a = "string" 12 | a = 1 13 | a = false 14 | fmt.Println("a =", a) 15 | } 16 | func show_reflection() { 17 | fmt.Println("\nshow_reflection()") 18 | var x float64 = 3.4 19 | v := reflect.ValueOf(x) 20 | fmt.Println("type:", v.Type()) 21 | fmt.Println("kind is float64:", v.Kind() == reflect.Float64) 22 | fmt.Println("value:", v.Float()) 23 | 24 | p := reflect.ValueOf(&x) 25 | newX := p.Elem() 26 | newX.SetFloat(7.1) 27 | fmt.Println("newX =", newX) 28 | fmt.Println("newX float64() value:", newX.Float()) 29 | } 30 | func main() { 31 | show_interface_none() 32 | show_reflection() 33 | } 34 | -------------------------------------------------------------------------------- /en/eBook/01.5.md: -------------------------------------------------------------------------------- 1 | # 1.5 Summary 2 | 3 | In this chapter, we talked about how to install Go using three different methods including from source code, the standard package and via third-party tools. Then we showed you how to configure the Go development environment, mainly covering how to setup your `$GOPATH`. After that, we introduced some steps for compiling and deploying Go programs. We then covered Go commands, including the compile, install, format and test commands. Finally, there are many powerful tools to develop Go programs such as LiteIDE, Sublime Text, Vim, Emacs, Eclipse, IntelliJ IDEA, etc. You can choose any one you like exploring the world of Go. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [Go development tools](01.4.md) 9 | - Next chapter: [Go basic knowledge](02.0.md) 10 | -------------------------------------------------------------------------------- /en/eBook/05.7.md: -------------------------------------------------------------------------------- 1 | # 5.7 Summary 2 | 3 | In this chapter, you first learned about the design of the `database/sql` interface and many third-party database drivers for various database types. Then I introduced beedb, an ORM for relational databases, to you. I also showed you some sample database operations. In the end, I talked about a few NoSQL databases. We saw that Go provides very good support for those NoSQL databases. 4 | 5 | After reading this chapter, I hope that you have a better understanding of how to operate databases in Go. This is the most important part of web development, so I want you to completely understand the design concepts of the `database/sql` interface. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous section: [NoSQL database](05.6.md) 11 | - Next section: [Data storage and session](06.0.md) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/pass_by_value_and_pointer/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Shows passing a variable by value and reference 3 | package main 4 | 5 | import "fmt" 6 | 7 | func add_by_value(a int) int { 8 | a = a + 1 9 | return a 10 | } 11 | func add_by_reference(a *int) int { 12 | *a = *a + 1 13 | return *a 14 | } 15 | func show_add_by_value() { 16 | x := 3 17 | fmt.Println("x = ", x) 18 | fmt.Println("add_by_value(x) =", add_by_value(x) ) 19 | fmt.Println("x = ", x) 20 | } 21 | func show_add_by_reference() { 22 | x := 3 23 | fmt.Println("x = ", x) 24 | // &x pass memory address of x 25 | fmt.Println("add_by_reference(&x) =", add_by_reference(&x) ) 26 | fmt.Println("x = ", x) 27 | } 28 | func main() { 29 | show_add_by_value() 30 | show_add_by_reference() 31 | } 32 | -------------------------------------------------------------------------------- /ebook/11.0.md: -------------------------------------------------------------------------------- 1 | # 11 错误处理,调试和测试 2 | 我们经常会看到很多程序员大部分的"编程"时间都花费在检查bug和修复bug上。无论你是在编写修改代码还是重构系统,几乎都是花费大量的时间在进行故障排除和测试,外界都觉得我们程序员是设计师,能够把一个系统从无做到有,是一项很伟大的工作,而且是相当有趣的工作,但事实上我们每天都是徘徊在排错、调试、测试之间。当然如果你有良好的习惯和技术方案来直面这些问题,那么你就有可能将排错时间减到最少,而尽可能的将时间花费在更有价值的事情上。 3 | 4 | 但是遗憾的是很多程序员不愿意在错误处理、调试和测试能力上下工夫,导致后面应用上线之后查找错误、定位问题花费更多的时间。所以我们在设计应用之前就做好错误处理规划、测试用例等,那么将来修改代码、升级系统都将变得简单。 5 | 6 | 开发Web应用过程中,错误自然难免,那么如何更好的找到错误原因,解决问题呢?11.1小节将介绍Go语言中如何处理错误,如何设计自己的包、函数的错误处理,11.2小节将介绍如何使用GDB来调试我们的程序,动态运行情况下各种变量信息,运行情况的监控和调试。 7 | 8 | 11.3小节将对Go语言中的单元测试进行深入的探讨,并示例如何来编写单元测试,Go的单元测试规则规范如何定义,以保证以后升级修改运行相应的测试代码就可以进行最小化的测试。 9 | 10 | 长期以来,培养良好的调试、测试习惯一直是很多程序员逃避的事情,所以现在你不要再逃避了,就从你现在的项目开发,从学习Go Web开发开始养成良好的习惯。 11 | 12 | ## 目录 13 | 14 | ![](images/navi11.png?raw=true) 15 | 16 | ## links 17 | * [目录]() 18 | * 上一章: [第十章总结](<10.4.md>) 19 | * 下一节: [错误处理](<11.1.md>) -------------------------------------------------------------------------------- /ebook/04.0.md: -------------------------------------------------------------------------------- 1 | # 4 表单 2 | 3 | 表单是我们平常编写Web应用常用的工具,通过表单我们可以方便的让客户端和服务器进行数据的交互。对于以前开发过Web的用户来说表单都非常熟悉,但是对于C/C++程序员来说,这可能是一个有些陌生的东西,那么什么是表单呢? 4 | 5 | 表单是一个包含表单元素的区域。表单元素是允许用户在表单中(比如:文本域、下拉列表、单选框、复选框等等)输入信息的元素。表单使用表单标签(\)定义。 6 | 7 |
8 | ... 9 | input 元素 10 | ... 11 |
12 | 13 | Go里面对于form处理已经有很方便的方法了,在Request里面的有专门的form处理,可以很方便的整合到Web开发里面来,4.1小节里面将讲解Go如何处理表单的输入。由于不能信任任何用户的输入,所以我们需要对这些输入进行有效性验证,4.2小节将就如何进行一些普通的验证进行详细的演示。 14 | 15 | HTTP协议是一种无状态的协议,那么如何才能辨别是否是同一个用户呢?同时又如何保证一个表单不出现多次递交的情况呢?4.3和4.4小节里面将对cookie(cookie是存储在客户端的信息,能够每次通过header和服务器进行交互的数据)等进行详细讲解。 16 | 17 | 表单还有一个很大的功能就是能够上传文件,那么Go是如何处理文件上传的呢?针对大文件上传我们如何有效的处理呢?4.5小节我们将一起学习Go处理文件上传的知识。 18 | 19 | ## 目录 20 | ![](images/navi4.png?raw=true) 21 | 22 | ## links 23 | * [目录]() 24 | * 上一章: [第三章总结](<03.5.md>) 25 | * 下一节: [处理表单的输入](<04.1.md>) 26 | -------------------------------------------------------------------------------- /en/eBook/10.4.md: -------------------------------------------------------------------------------- 1 | # 10.4 Summary 2 | 3 | Through this introductory chapter on i18n, you should now be familiar with some of the steps and processes that are necessary for internationalizing and localizing your websites. I've also introduced an open source solution for i18n in Go: [go-i18n](https://github.com/astaxie/go-i18n). Using this open source library, we can easily implement multi-language versions of our web applications. This allows our applications to be flexible and responsive to local audiences all around the world. If you find an error in this open source library or any missing features, please open an issue or a pull request! Let's strive to make it one of Go's standard libraries! 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [International sites](10.3.md) 9 | - Next chapter: [Error handling, debugging and testing](11.0.md) 10 | -------------------------------------------------------------------------------- /ja/ebook/14.0.md: -------------------------------------------------------------------------------- 1 | # 14 Webフレームワークの拡張 2 | 第13章においてWebフレームワークの開発をご紹介しました。MVC、ルーティング、ログ処理、設定処理の紹介を通じて基本的なフレームワークシステムを完成しました。しかしより良いフレームワークは便利な補助ツールでもって素早いWeb開発を行うものです。ではこの章ではどのように素早くWeb開発を行うツールを利用するかについてご紹介していきましょう。第1章で静的なファイルをどのように処理するかご紹介しました。現在あるtwitterのオープンソースのbootstrapをどのように利用することで素早く美しいホームページを開発するか、第二節では前にご紹介したsessionを使ってどのようにユーザのログイン処理を行うかについてご紹介します。第3節ではどのように簡便にフォームを出力し、どのようにフォームのデータの検証を行うか、また、どのように素早くmodelと結合してデータの追加、削除、修正といった操作を行うかご紹介しました。第4節ではどのようにユーザの認証をおこなうかご紹介しました。http basci認証、http digest認証を含みます。第5節では前にご紹介したi18nを使ってどのように多言語をサポートアプリケーションを開発するかご紹介しました。 3 | 4 | この章の拡張を通して、beegoフレームワークが素早いWeb開発の特徴を有することになります。最後にどのようにこれらの拡張の特徴を利用して第13章で開発したブログシステムを拡張するかご紹介しましょう。完全で美しいブログシステムを開発することで、読者はbeego開発があなたに与えるスピードをご理解いただけると思います。 5 | 6 | ## 目次 7 | ![](images/navi14.png?raw=true) 8 | 9 | ## links 10 | * [目次]() 11 | * 前へ: [第13章まとめ](<13.6.md>) 12 | * 次へ: [静的なファイルのサポート](<14.1.md>) 13 | -------------------------------------------------------------------------------- /ja/ebook/01.0.md: -------------------------------------------------------------------------------- 1 | # 1 GOの環境設定 2 | 3 | Goの世界へようこそ、さっそく初めてみましょう! 4 | 5 | Goは新しい言語です、並列処理、ガベージコレクションを備え、軽快にプログラムできる言語です。以下のような特徴を持っています: 6 | 7 | - 一台のコンピュータ上であっという間に大型のGoプログラムを作り出すことができます。 8 | - Goはソフトウェアの構造にモデルを提供します。分析をより簡単にこなせ、Cスタイルの頭にありがちなファイルとライブラリのincludeの大部分を省くことができます。 9 | - Goは静的型付け言語です。型には階層がありません。このためユーザは型の定義の関係に時間をとられることなく、典型的なオブジェクト指向言語よりももっとライトに感じるくらいです。 10 | - Goは完全にガベージコレクションタイプの言語です。また、並列処理とネットワークを基本的にサポートしています。 11 | - Goはマルチプロセッサ対応のソフトウェアを作成できるようデザインされています。 12 | 13 | Goはコンパイラ型言語の一種です。インタプリタ型言語の軽い身のこなしと動的型付け言語の開発効率、それに静的型付け言語の安全性を兼ね備えています。また、モダンにネットワークとマルチプロセッサもサポートしています。これらの目標を達成するには、解決しなければならない言語上の問題がいくつかあります:表現力豊かだけれども軽いシステム、並列処理とガベージコレクション、厳格な依存定義などです。これらはライブラリやツール無しにはうまくいきません。Goもその要望に応えます。 14 | 15 | この章ではGoのインストール方法と設定について述べます。 16 | 17 | ## 目次 18 | 19 | ![](images/navi1.png?raw=true) 20 | 21 | ## links 22 | * [目次]() 23 | * 次へ: [Goのインストール](<01.1.md>) 24 | -------------------------------------------------------------------------------- /ebook/10.0.md: -------------------------------------------------------------------------------- 1 | # 10 国际化和本地化 2 | 为了适应经济的全球一体化,作为开发者,我们需要开发出支持多国语言、国际化的Web应用,即同样的页面在不同的语言环境下需要显示不同的效果,也就是说应用程序在运行时能够根据请求所来自的地域与语言的不同而显示不同的用户界面。这样,当需要在应用程序中添加对新的语言的支持时,无需修改应用程序的代码,只需要增加语言包即可实现。 3 | 4 | 国际化与本地化(Internationalization and localization,通常用i18n和L10N表示),国际化是将针对某个地区设计的程序进行重构,以使它能够在更多地区使用,本地化是指在一个面向国际化的程序中增加对新地区的支持。 5 | 6 | 目前,Go语言的标准包没有提供对i18n的支持,但有一些比较简单的第三方实现,这一章我们将实现一个go-i18n库,用来支持Go语言的i18n。 7 | 8 | 所谓的国际化:就是根据特定的locale信息,提取与之相应的字符串或其它一些东西(比如时间和货币的格式)等等。这涉及到三个问题: 9 | 10 | 1、如何确定locale。 11 | 12 | 2、如何保存与locale相关的字符串或其它信息。 13 | 14 | 3、如何根据locale提取字符串和其它相应的信息。 15 | 16 | 在第一小节里,我们将介绍如何设置正确的locale以便让访问站点的用户能够获得与其语言相应的页面。第二小节将介绍如何处理或存储字符串、货币、时间日期等与locale相关的信息,第三小节将介绍如何实现国际化站点,即如何根据不同locale返回不同合适的内容。通过这三个小节的学习,我们将获得一个完整的i18n方案。 17 | 18 | ## 目录 19 | 20 | ![](images/navi10.png?raw=true) 21 | 22 | ## links 23 | * [目录]() 24 | * 上一章: [第九章总结](<09.7.md>) 25 | * 下一节: [设置默认地区](<10.1.md>) 26 | -------------------------------------------------------------------------------- /ja/ebook/05.0.md: -------------------------------------------------------------------------------- 1 | # 5 データベースへのアクセス 2 | 多くのWebアプリケーションプログラムにおいて、データベースはその核心となるものです。データベースはあなたが検索やさまざまな情報を修正したい場合にはほとんどで使用されます。例えばユーザ情報や製品の目録またはニュースのリスト等です。 3 | 4 | Goはどのようなデータベースの使用もbuiltinではサポートされていません。しかし、Goはdatabase/sqlインターフェースを定義していますので、ユーザはこのドライバインターフェースに基いて目的のデータベースを使用することができます。5.1節でGoでデザインされているいくつかのドライバインターフェースやデータベースドライバインターフェースをご紹介します。5.2から5.4節では現在比較的使用されている関係型データドリブンとその使用方法についてご紹介します。5.5節では私が開発したORMライブラリをご紹介します。database/sqlの標準インターフェースに基づいた開発です。ほぼ全てのdatabase/sqlをサポートするデータベースの使用に互換性があります。Goスタイルで簡単にデータベース操作を行うことができます。 5 | 6 | 現在NOSQLはすでにWeb開発の流行となっています。多くのアプリケーションがNOSQLをデータベースとして採用しています。以前のキャッシュではありません。5.6節ではMongoDBとRedisの2つのNOSQLデータベースについてご紹介します。 7 | 8 | >[Go database/sql tutorial](http://go-database-sql.org/)ではよく使われる例と詳細な説明を提供しています。 9 | 10 | ## 目次 11 | ![](images/navi5.png?raw=true) 12 | 13 | ## links 14 | * [目次]() 15 | * 前へ: [第四章まとめ](<04.6.md>) 16 | * 次へ: [database/sqlインターフェース](<05.1.md>) 17 | -------------------------------------------------------------------------------- /en/eBook/06.5.md: -------------------------------------------------------------------------------- 1 | # 6.5 Summary 2 | 3 | In this chapter, we learned about the definition and purpose of sessions and cookies, and the relationship between the two. Since Go doesn't support sessions in its standard library, we also designed our own session manager. We went through the everything from creating client sessions to deleting them. We then defined an interface called `Provider` which supports all session storage structures. In section 6.3, we implemented a memory based session manager to persist client data across sessions. In section 6.4, I show you one way of hijacking a session. Then we looked at how to prevent your own sessions from being hijacked. I hope that you now understand most of the working principles behind sessions so that you're able to safely use them in your applications. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [Prevent session hijacking](06.4.md) 9 | - Next chapter: [Text files](07.0.md) 10 | -------------------------------------------------------------------------------- /ebook/09.0.md: -------------------------------------------------------------------------------- 1 | # 9 安全与加密 2 | 无论是开发Web应用的开发者还是企图利用Web应用漏洞的攻击者,对于Web程序安全这个话题都给予了越来越多的关注。特别是最近CSDN密码泄露事件,更是让我们对Web安全这个话题更加重视,所有人都谈密码色变,都开始检测自己的系统是否存在漏洞。那么我们作为一名Go程序的开发者,一定也需要知道我们的应用程序随时会成为众多攻击者的目标,并提前做好防范的准备。 3 | 4 | 很多Web应用程序中的安全问题都是由于轻信了第三方提供的数据造成的。比如对于用户的输入数据,在对其进行验证之前都应该将其视为不安全的数据。如果直接把这些不安全的数据输出到客户端,就可能造成跨站脚本攻击(XSS)的问题。如果把不安全的数据用于数据库查询,那么就可能造成SQL注入问题,我们将会在9.3、9.4小节介绍如何避免这些问题。 5 | 6 | 在使用第三方提供的数据,包括用户提供的数据时,首先检验这些数据的合法性非常重要,这个过程叫做过滤,我们将在9.2小节介绍如何保证对所有输入的数据进行过滤处理。 7 | 8 | 过滤输入和转义输出并不能解决所有的安全问题,我们将会在9.1讲解的CSRF攻击,会导致受骗者发送攻击者指定的请求从而造成一些破坏。 9 | 10 | 与安全加密相关的,能够增强我们的Web应用程序的强大手段就是加密,CSDN泄密事件就是因为密码保存的是明文,使得攻击拿手库之后就可以直接实施一些破坏行为了。不过,和其他工具一样,加密手段也必须运用得当。我们将在9.5小节介绍如何存储密码,如何让密码存储的安全。 11 | 12 | 加密的本质就是扰乱数据,某些不可恢复的数据扰乱我们称为单向加密或者散列算法。另外还有一种双向加密方式,也就是可以对加密后的数据进行解密。我们将会在9.6小节介绍如何实现这种双向加密方式。 13 | 14 | ## 目录 15 | ![](images/navi9.png?raw=true) 16 | 17 | ## links 18 | * [目录]() 19 | * 上一章: [第八章总结](<08.5.md>) 20 | * 下一节: [预防CSRF攻击](<09.1.md>) 21 | -------------------------------------------------------------------------------- /ebook/02.8.md: -------------------------------------------------------------------------------- 1 | # 2.8 总结 2 | 3 | 这一章我们主要介绍了Go语言的一些语法,通过语法我们可以发现Go是多么的简单,只有二十五个关键字。让我们再来回顾一下这些关键字都是用来干什么的。 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | - var和const参考2.2Go语言基础里面的变量和常量申明 12 | - package和import已经有过短暂的接触 13 | - func 用于定义函数和方法 14 | - return 用于从函数返回 15 | - defer 用于类似析构函数 16 | - go 用于并发 17 | - select 用于选择不同类型的通讯 18 | - interface 用于定义接口,参考2.6小节 19 | - struct 用于定义抽象数据类型,参考2.5小节 20 | - break、case、continue、for、fallthrough、else、if、switch、goto、default这些参考2.3流程介绍里面 21 | - chan用于channel通讯 22 | - type用于声明自定义类型 23 | - map用于声明map类型数据 24 | - range用于读取slice、map、channel数据 25 | 26 | 上面这二十五个关键字记住了,那么Go你也已经差不多学会了。 27 | 28 | ## links 29 | * [目录]() 30 | * 上一节: [并发](<02.7.md>) 31 | * 下一章: [Web基础](<03.0.md>) 32 | -------------------------------------------------------------------------------- /ebook/08.0.md: -------------------------------------------------------------------------------- 1 | # 8 Web服务 2 | Web服务可以让你在HTTP协议的基础上通过XML或者JSON来交换信息。如果你想知道上海的天气预报、中国石油的股价或者淘宝商家的一个商品信息,你可以编写一段简短的代码,通过抓取这些信息然后通过标准的接口开放出来,就如同你调用一个本地函数并返回一个值。 3 | 4 | Web服务背后的关键在于平台的无关性,你可以运行你的服务在Linux系统,可以与其他Window的asp.net程序交互,同样的,也可以通过同一个接口和运行在FreeBSD上面的JSP无障碍地通信。 5 | 6 | 目前主流的有如下几种Web服务:REST、SOAP。 7 | 8 | REST请求是很直观的,因为REST是基于HTTP协议的一个补充,他的每一次请求都是一个HTTP请求,然后根据不同的method来处理不同的逻辑,很多Web开发者都熟悉HTTP协议,所以学习REST是一件比较容易的事情。所以我们在8.3小节讲详细的讲解如何在Go语言中来实现REST方式。 9 | 10 | SOAP是W3C在跨网络信息传递和远程计算机函数调用方面的一个标准。但是SOAP非常复杂,其完整的规范篇幅很长,而且内容仍然在增加。Go语言是以简单著称,所以我们不会介绍SOAP这样复杂的东西。而Go语言提供了一种天生性能很不错,开发起来很方便的RPC机制,我们将会在8.4小节详细介绍如何使用Go语言来实现RPC。 11 | 12 | Go语言是21世纪的C语言,我们追求的是性能、简单,所以我们在8.1小节里面介绍如何使用Socket编程,很多游戏服务都是采用Socket来编写服务端,因为HTTP协议相对而言比较耗费性能,让我们看看Go语言如何来Socket编程。目前随着HTML5的发展,webSockets也逐渐的成为很多页游公司接下来开发的一些手段,我们将在8.2小节里面讲解Go语言如何编写webSockets的代码。 13 | 14 | ## 目录 15 | ![](images/navi8.png?raw=true) 16 | 17 | ## links 18 | * [目录]() 19 | * 上一章: [第七章总结](<07.7.md>) 20 | * 下一节: [Socket编程](<08.1.md>) 21 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.3.2/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 3.2 from "Build Web Application with Golang" 2 | // Purpose: Shows how to acces the form values from the request 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "log" 8 | "net/http" 9 | "strings" 10 | ) 11 | 12 | func sayhelloName(w http.ResponseWriter, r *http.Request) { 13 | r.ParseForm() // parse arguments, you have to call this by yourself 14 | fmt.Println(r.Form) // print form information in server side 15 | fmt.Println("path", r.URL.Path) 16 | fmt.Println("scheme", r.URL.Scheme) 17 | fmt.Println(r.Form["url_long"]) 18 | for k, v := range r.Form { 19 | fmt.Println("key:", k) 20 | fmt.Println("val:", strings.Join(v, "")) 21 | } 22 | fmt.Fprintf(w, "Hello astaxie!") // send data to client side 23 | } 24 | 25 | func main() { 26 | http.HandleFunc("/", sayhelloName) // set router 27 | err := http.ListenAndServe(":9090", nil) // set listen port 28 | if err != nil { 29 | log.Fatal("ListenAndServe: ", err) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /en/eBook/13.6.md: -------------------------------------------------------------------------------- 1 | # 13.6 Summary 2 | 3 | In this chapter we describe how to implement a major foundation of the Go language framework, which includes routing design due to the built-in http Go package routing some shortcomings, we have designed a dynamic routing rule, and then introduces the MVC pattern Controller design, controller implements the REST implementation, the main ideas from the tornado frame, and then design and implement the template layout and automated rendering technology, mainly using the Go built-in template engine, and finally we introduce some auxiliary logs, configuration, etc. information design, through these designs we implemented a basic framework beego, present the framework has been open in GitHub, finally we beego implemented a blog system, through a detailed example code demonstrates how to quickly develop a site. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [Add, delete and update blogs](13.5.md) 9 | - Next chapter: [Develop web framework](14.0.md) 10 | -------------------------------------------------------------------------------- /ja/ebook/14.7.md: -------------------------------------------------------------------------------- 1 | # 14.7 まとめ 2 | この章は主にどのようにしてbeegoフレームワークにもとづいて展開を行うかについて詳しく述べました。これには静的なファイルのサポートが含まれます。第1節では静的なファイルでは主にどのようにしてbeegoを利用して素早くウェブページを開発するか、bootstrapを利用して美しいサイトの作成についてご紹介しました;第2節ではどのようにしてbeegoにおいてsessionManagerを構成するかについてご紹介しました。これはユーザがbeegoを利用した時に素早くsessionを利用するのに便利です;第3節ではフォームとバリデーションについてご紹介しました。Go言語のstructの定義に基づくと、Webを開発する過程で重複する作業から解放されます。また、バリデーションを追加するとできるかぎりデータを安全にすることができます。第4節ではユーザの認証についてご紹介しました。ユーザの認証は主に3つの需要があります。http basicとhttp digest認証、サードパーティ認証、カスタム定義の認証です。コードを用いてどのようにして現在あるサードパーティパッケージからbeegoアプリケーションでこれらの認証を実装するのかデモを行いました。第5節では多言語サポートをご紹介しました。beegoではgo-i18nという多言語パッケージを使用しています。ユーザはとても簡単にこのライブラリを利用して多言語Webアプリケーションを開発することができます。第6節ではどのようにしてGoのpprofパッケージを利用するのかご紹介しました。pprofパッケージは性能テストに使われるツールです。beegoに対する改造を施した後pprofパッケージを使うことでユーザはpprofからbeegoにもとづいて開発されたアプリケーションのテストを行うことができます。これら6つの節を通して比較的健全なbeegoフレームワークを展開してきました。このフレームワークは現在の数多くのWebアプリケーションに十分対応することができます。ユーザは自身の相続力を継続して発揮することができます。私はここで簡単にいくつか重要と思われる拡張についてご紹介したにすぎません。 3 | 4 | ## links 5 | * [目次]() 6 | * 前へ: [pprofのサポート](<14.6.md>) 7 | -------------------------------------------------------------------------------- /ja/ebook/06.0.md: -------------------------------------------------------------------------------- 1 | # 6 sessionとデータの保存 2 | Web開発ではどのようにしてユーザの閲覧過程のすべてをコントロールするかということは非常に重要です。HTTPプロトコルはステートレスですので、ユーザの毎回のリクエストにはステータスがありません。Web操作の全体の過程の中でどの接続がどのユーザと関係しているのか知る方法がありません。では、どのようにしてこの問題を解決しているのでしょうか?Webでの伝統的な解決方法はcookieとsessionです。cookieによるメカニズムはクライアント側でのメカニズムです。ユーザのデータをクライアントに保存します。sessionメカニズムはサーバ側でのメカニズムです。サーバはハッシュテーブルのような構造でデータを保存します。ホームページの各閲覧者はユニークなIDを与えられます。すなわち、SessionIDです。この保存形式は2つだけです:urlによって渡されるか、クライアントのcookieに保存されるかです。当然、Sessionをデータベースに保存することもできます。よりセキュリティが高まりますが、効率の面ではいくつか後退します。 3 | 4 | 6.1節ではsessionメカニズムとcookieメカニズムの関係と区別についてご紹介します。6.2ではGo言語がどのようにsessionを実現しているかご説明します。この中では簡単なsessionマネージャを実現します。6.3節ではどのようにしてsessionハイジャックの状態を防ぐかご説明します。どのように効果的にsessionを保護するのか。sessionはそもそもどのようなところに保存してもよいのです。6.3節ではsessionをメモリの中に保存しますが、我々のアプリケーションをもう一歩展開させる場合、アプリケーションのsession共有を実現する必要があります。sessionをデータベースの中(memcachedまたはredis)に保存します。6.4節ではどのようにしてこの機能を実装するかご説明します。 5 | 6 | ## 目次 7 | ![](images/navi6.png?raw=true) 8 | 9 | ## links 10 | * [目次]() 11 | * 前へ: [第五章まとめ](<05.7.md>) 12 | * 次へ: [sessionとcookie](<06.1.md>) 13 | -------------------------------------------------------------------------------- /ja/ebook/07.0.md: -------------------------------------------------------------------------------- 1 | # 7 テキスト処理 2 | Web開発においてテキスト処理は非常に重要な要素です。往々にして出力または入力する内容に対して処理を行う必要があります。ここでのテキストには文字列、数字、Json、XML等々が含まれます。高性能な一言語としてのGo言語では、これらのテキストの処理はすべてオフィシャルの標準パッケージにサポートされています。また利用中にGo標準ライブラリが巧みに設計されていることに気がつくでしょう。またユーザからすれば非常に簡単にこれらのテキストを処理することができます。本章では4つの節を通してユーザにGo言語のテキスト処理のよい知識をご紹介したいきたいと思います。 3 | 4 | XMLは現在多くの標準インターフェースの対話型言語となっています。多くの場合Javaで書かれたwebserverとのやりとりはどれもXML標準にもとづいて行われます。7.1節ではどのようにXMLテキストを処理するかご紹介します。XMLを使用した後あまりに複雑だと気づきます。現在多くのインターネット企業の対外的なAPIでは多くがJSON形式を採用しています。この形式は描写が簡単ですが、意味をよく表現することができます。7.2節ではどのようにこういったJSON形式のデータを処理するかご説明します。正規表現は人に愛され、また恨まれる道具です。このテキスト処理能力は非常に協力です。我々は前のフォームの検証でその強力さをすでに味わっています。7.3節ではどのようにGoの正規表現を利用するのがよいかより詳しく解説していきます。Web開発において非常に重要な部分としてMVCの分離があります。Go言語ではWeb開発中Vにおいて`template`という専門的にサポートするパッケージがあります。7.4節ではテンプレートをつかってコンテンツをどのように出力するのか詳細に解説していきます。7.5節ではどのようにしてファイルとディレクトリを操作するのか詳しくご紹介します。7.6節のまとめでは文字列に関する操作についてご紹介します。 5 | 6 | ## 目次 7 | ![](images/navi7.png?raw=true) 8 | 9 | ## links 10 | * [目次]() 11 | * 前へ: [第六章まとめ](<06.5.md>) 12 | * 次へ: [XMLの処理](<07.1.md>) 13 | -------------------------------------------------------------------------------- /en/eBook/02.0.md: -------------------------------------------------------------------------------- 1 | # 2 Go basic knowledge 2 | 3 | Go is a compiled system programming language, and it belongs to the C-family. However, its compilation speed is much faster than other C-family languages. It has only 25 keywords... even less than the 26 letters of the English alphabet! Let's take a look at these keywords before we get started. 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | In this chapter, I'm going to teach you some basic Go knowledge. You will find out how concise the Go programming language is, and the beautiful design of the language. Programming can be very fun in Go. After we complete this chapter, you'll be familiar with the above keywords. 12 | 13 | ## Links 14 | 15 | - [Directory](preface.md) 16 | - Previous chapter: [Chapter 1 Summary](01.5.md) 17 | - Next section: ["Hello, Go"](02.1.md) 18 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.6/switch_type_check/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | type Element interface{} 9 | type List []Element 10 | 11 | type Person struct { 12 | name string 13 | age int 14 | } 15 | 16 | func (p Person) String() string { 17 | return "(name: " + p.name + " - age: " + strconv.Itoa(p.age) + " years)" 18 | } 19 | 20 | func main() { 21 | list := make(List, 3) 22 | list[0] = 1 //an int 23 | list[1] = "Hello" //a string 24 | list[2] = Person{"Dennis", 70} 25 | 26 | for index, element := range list { 27 | switch value := element.(type) { 28 | case int: 29 | fmt.Printf("list[%d] is an int and its value is %d\n", index, value) 30 | case string: 31 | fmt.Printf("list[%d] is a string and its value is %s\n", index, value) 32 | case Person: 33 | fmt.Printf("list[%d] is a Person and its value is %s\n", index, value) 34 | default: 35 | fmt.Println("list[%d] is of a different type", index) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ja/ebook/13.0.md: -------------------------------------------------------------------------------- 1 | # 13 どのようにしてWebフレームワークを設計するか 2 | 前の12章ではGoを使ってどのようにWebアプリケーションを開発するかについてご紹介しました。多くの基礎的な知識、開発ツールおよび開発テクニックをご紹介したので、この章ではこれらの知識を通じて簡単なWebフレームワークを実装してみましょう。Go言語を通じて完全なフレームワークを設計します。このフレームワークでは主に第1章でご紹介したWebフレームワークの構造ルールを含みます。例えば、MVCモードを採用して開発を行う場合の、プログラムの実行プロセス設計といった内容;第2章でご紹介したフレームワークの1つ目の機能:ルーティング、どのようにしてアクセスされたURLを対応する処理ロジックに投影するか;第3章でご紹介した処理ロジック、どのようにパブリックなcontrollerを設計するか、オブジェクトを継承した後処理関数にてどのようにresponseとrequestを処理するか;第4章ではフレームワークの一部の補助機能をご紹介しました。例えばログ処理、設定情報などです;第5章ではWebフレームワークに基いてどのようにブログを実装するかについてご紹介しました。これにはブログの投稿、修正、削除、リストの表示といった操作を含みます。 3 | 4 | この完全な項目の例を通じて、読者におかれましてはどのようにWebアプリケーションを開発するか、どのように自分のディレクトリ構造を作成するか、どのようにルーティングを実装するか、どのようにMVCモードといった各方面の開発コンテンツを実装するかご理解いただけたものと期待しております。フレームワークが盛り上がりを見せる昨今、MVCはもはや神話ではありません。プログラマがどのフレームワークが良いか、どれがダメかと討論しているのを多く見かけるようになりました。フレームワークはツールにすぎません。本来良いも悪いもないのです。そこにはただ適切か不適切かのみが存在します。自分に合えばそれが最良ですので、みなさんに自分の手でフレームワークを書くことをお教えできれば、異なった需要に対しても自分の思考に合わせて実装することができるようになります。 5 | 6 | ## 目次 7 | ![](images/navi13.png?raw=true) 8 | 9 | ## links 10 | * [目次]() 11 | * 前へ: [第12章まとめ](<12.5.md>) 12 | * 次へ: [プロジェクトのプラン](<13.1.md>) 13 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.4/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.4 from "Build Web Application with Golang" 2 | // Purpose: Shows different ways of creating a struct 3 | package main 4 | 5 | import "fmt" 6 | 7 | func show_basic_struct() { 8 | fmt.Println("\nshow_basic_struct()") 9 | type person struct { 10 | name string 11 | age int 12 | } 13 | 14 | var P person // p is person type 15 | 16 | P.name = "Astaxie" // assign "Astaxie" to the filed 'name' of p 17 | P.age = 25 // assign 25 to field 'age' of p 18 | fmt.Printf("The person's name is %s\n", P.name) // access field 'name' of p 19 | 20 | tom := person{"Tom", 25} 21 | 22 | bob := person{age: 24, name: "Bob"} 23 | 24 | fmt.Printf("tom = %+v\n", tom) 25 | fmt.Printf("bob = %#v\n", bob) 26 | } 27 | func show_anonymous_struct() { 28 | fmt.Println("\nshow_anonymous_struct()") 29 | fmt.Printf("Anonymous struct = %#v\n", struct { 30 | name string 31 | count int 32 | }{ 33 | "counter", 1, 34 | }) 35 | } 36 | func main() { 37 | show_basic_struct() 38 | show_anonymous_struct() 39 | } 40 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.5/client_upload/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "io/ioutil" 8 | "mime/multipart" 9 | "net/http" 10 | "os" 11 | ) 12 | 13 | func checkError(err error) { 14 | if err != nil { 15 | panic(err) 16 | } 17 | } 18 | func postFile(filename string, targetUrl string) { 19 | bodyBuf := &bytes.Buffer{} 20 | bodyWriter := multipart.NewWriter(bodyBuf) 21 | fileWriter, err := bodyWriter.CreateFormFile("uploadfile", filename) 22 | checkError(err) 23 | 24 | fh, err := os.Open(filename) 25 | checkError(err) 26 | 27 | _, err = io.Copy(fileWriter, fh) 28 | checkError(err) 29 | 30 | contentType := bodyWriter.FormDataContentType() 31 | bodyWriter.Close() 32 | resp, err := http.Post(targetUrl, contentType, bodyBuf) 33 | checkError(err) 34 | 35 | defer resp.Body.Close() 36 | resp_body, err := ioutil.ReadAll(resp.Body) 37 | checkError(err) 38 | 39 | fmt.Println(resp.Status) 40 | fmt.Println(string(resp_body)) 41 | } 42 | func main() { 43 | target_url := "http://localhost:9090/upload" 44 | filename := "../file.txt" 45 | postFile(filename, target_url) 46 | } 47 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.6/type_check/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | type Element interface{} 9 | type List []Element 10 | 11 | type Person struct { 12 | name string 13 | age int 14 | } 15 | 16 | func (p Person) String() string { 17 | return "(name: " + p.name + " - age: " + strconv.Itoa(p.age) + " years)" 18 | } 19 | 20 | func main() { 21 | list := make(List, 3) 22 | list[0] = 1 // an int 23 | list[1] = "Hello" // a string 24 | list[2] = Person{"Dennis", 70} 25 | 26 | for index, element := range list { 27 | if value, ok := element.(int); ok { 28 | fmt.Printf("list[%d] is an int and its value is %d\n", index, value) 29 | } else if value, ok := element.(string); ok { 30 | fmt.Printf("list[%d] is a string and its value is %s\n", index, value) 31 | } else if value, ok := element.(Person); ok { 32 | fmt.Printf("list[%d] is a Person and its value is %s\n", index, value) 33 | } else { 34 | fmt.Println("list[%d] is of a different type", index) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ja/ebook/04.0.md: -------------------------------------------------------------------------------- 1 | # 4 フォーム 2 | 3 | フォームは我々が普段Webアプリケーションを書く時によく使うツールです。フォームを通して便利にユーザにサーバとデータをやり取りさせることができます。以前にWeb開発をしたことのあるユーザにとってはフォームはとてもお馴染みのものです。しかしC/C++のプログラマからすると、少々ばかり門外漢かもしれません。フォームとは一体何でしょうか? 4 | 5 | フォームは表の要素を含むエリアです。フォームの要素はユーザがフォームの中で(例えば、テキストフィールド、コンボボックス、チェックボックス、セレクトボックス等です。)情報を入力する要素です。フォームはフォームタグ(\)で定義します。 6 | 7 |
8 | ... 9 | input 要素 10 | ... 11 |
12 | 13 | Goではformの処理にすでにとても簡単な方法が用意されています。Requestの中にformを専門に処理するものがあります。とても簡単にWeb開発に利用できるものです。4.1節の中でGoがどのようにフォームの入力を処理するかご説明します。いかなるユーザの入力も信用はできないので、これらの入力に対しバリデーションを行う必要があります。4.2節ではどのように普通のバリデーションを行うか、細かいデモンストレーションを行います。 14 | 15 | HTTPプロトコルはステートレスなプロトコルです。ではどのようにして一人のユーザを同定するのでしょうか?また、フォームが複数回送信されてしまわないように保証するにはどうするのでしょうか?4.3と4.4節ではcookie(cookieはクライアントに保存される情報です。handlerとサーバを通る度にやり取りされるデータです。)等をより詳しくご紹介します。 16 | 17 | フォームにはもうひとつ、ファイルをアップロードできるという大きな機能があります。Goはファイルのアップロードをどのように処理しているのでしょうか?大きなファイルをアップロードする際効率よく処理するにはどうすればよいでしょうか?4.5節ではGoによるファイルのアップロード処理の知識を一緒に勉強します。 18 | 19 | ## 目次 20 | ![](images/navi4.png?raw=true) 21 | 22 | ## links 23 | * [目次]() 24 | * 前へ: [第三章まとめ](<03.5.md>) 25 | * 次へ: [フォームの入力を処理する](<04.1.md>) 26 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/type_function/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Shows how to define a function type 3 | package main 4 | 5 | import "fmt" 6 | 7 | type testInt func(int) bool // define a function type of variable 8 | 9 | func isOdd(integer int) bool { 10 | if integer%2 == 0 { 11 | return false 12 | } 13 | return true 14 | } 15 | 16 | func isEven(integer int) bool { 17 | if integer%2 == 0 { 18 | return true 19 | } 20 | return false 21 | } 22 | 23 | // pass the function `f` as an argument to another function 24 | 25 | func filter(slice []int, f testInt) []int { 26 | var result []int 27 | for _, value := range slice { 28 | if f(value) { 29 | result = append(result, value) 30 | } 31 | } 32 | return result 33 | } 34 | func init() { 35 | fmt.Println("\n#init() was called.") 36 | } 37 | func main() { 38 | slice := []int{1, 2, 3, 4, 5, 7} 39 | fmt.Println("slice = ", slice) 40 | odd := filter(slice, isOdd) // use function as values 41 | fmt.Println("Odd elements of slice are: ", odd) 42 | even := filter(slice, isEven) 43 | fmt.Println("Even elements of slice are: ", even) 44 | } 45 | -------------------------------------------------------------------------------- /ja/ebook/02.8.md: -------------------------------------------------------------------------------- 1 | # 2.8 まとめ 2 | 3 | この章では主にGo言語のいくつかの文法をご紹介しました。文法を通してGoがいかに簡単かご覧いただけたかと思います。たった25個のキーワードです。もう一度これらキーワードが何に使われるのか見てみることにしましょう。 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | - varとconstは2.2のGo言語の基礎に出てくる変数と定数の宣言を参考にしてください。 12 | - packageとimportにはすでに少し触れました。 13 | - func は関数とメソッドの定義に用いられます。 14 | - return は関数から返るために用いられます。 15 | - defer はデストラクタのようなものです。 16 | - go はマルチスレッドに用いられます。 17 | - select は異なる型の通信を選択するために用いられます。 18 | - interface はインターフェースを定義するために用いられます。2.6章をご参考ください。 19 | - struct は抽象データ型の定義に用いられます。2.5章をご参考ください。 20 | - break、case、continue、for、fallthrough、else、if、switch、goto、defaultは2.3のフロー紹介をご参考ください。 21 | - chanはchannel通信に用いられます。 22 | - typeはカスタム定義型の宣言に用いられます。 23 | - mapはmap型のデータの宣言に用いられます。 24 | - rangeはslice、map、channelデータの読み込みに用いられます。 25 | 26 | この25個のキーワードを覚えれば、Goは既に殆ど学び終わったも同然です。 27 | 28 | ## links 29 | * [目次]() 30 | * 前へ: [マルチスレッド](<02.7.md>) 31 | * 次へ: [Webの基礎](<03.0.md>) 32 | -------------------------------------------------------------------------------- /en/eBook/11.4.md: -------------------------------------------------------------------------------- 1 | # 11.4 Summary 2 | 3 | Over the course of the last three sections, we've introduced how to handle errors in Go, first looking at good error handling practices and design, then learning how to use the GDB debugger effectively. We saw that with GDB, we can perform single-step debugging, view and modify our program variables during execution, and print out the relevant process information. Finally, we described how to use Go's built-in `testing` framework to write unit and stress tests. Properly using this framework allows us to easily make any future changes to our code and perform the necessary regression testing. Good web applications must have good error handling, and part of that is having readable errors and error handling mechanisms which can scale in a predictable manner. Using the tools mentioned above as well as writing high quality and thorough unit and stress tests, we can have peace of mind knowing that once our applications are live, they can maintain optimal performance and run as expected. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [Write test cases](11.3.md) 9 | - Next chapter: [Deployment and maintenance](12.0.md) 10 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.3/import_packages/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.3 from "Build Web Application with Golang" 2 | // Purpose: Shows different ways of importing a package. 3 | // Note: For the package `only_call_init`, we reference the path from the 4 | // base directory of `$GOPATH/src`. The reason being Golang discourage 5 | // the use of relative paths when import packages. 6 | // BAD: "./only_call_init" 7 | // GOOD: "apps/ch.2.3/import_packages/only_call_init" 8 | package main 9 | 10 | import ( 11 | // `_` will only call init() inside the package only_call_init 12 | _ "apps/ch.2.3/import_packages/only_call_init" 13 | f "fmt" // import the package as `f` 14 | . "math" // makes the public methods and constants global 15 | "mymath" // custom package located at $GOPATH/src/ 16 | "os" // normal import of a standard package 17 | "text/template" // the package takes the name of last folder path, `template` 18 | ) 19 | 20 | func main() { 21 | f.Println("mymath.Sqrt(4) =", mymath.Sqrt(4)) 22 | f.Println("E =", E) // references math.E 23 | 24 | t, _ := template.New("test").Parse("Pi^2 = {{.}}") 25 | t.Execute(os.Stdout, Pow(Pi, 2)) 26 | } 27 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.4/embedded_structs/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.4 from "Build Web Application with Golang" 2 | // Purpose: Example of embedded fields 3 | package main 4 | 5 | import "fmt" 6 | 7 | type Human struct { 8 | name string 9 | age int 10 | weight int 11 | } 12 | 13 | type Student struct { 14 | Human // anonymous field, it means Student struct includes all fields that Human has. 15 | speciality string 16 | } 17 | 18 | func main() { 19 | // initialize a student 20 | mark := Student{Human{"Mark", 25, 120}, "Computer Science"} 21 | 22 | // access fields 23 | fmt.Println("His name is ", mark.name) 24 | fmt.Println("His age is ", mark.age) 25 | fmt.Println("His weight is ", mark.weight) 26 | fmt.Println("His speciality is ", mark.speciality) 27 | // modify notes 28 | mark.speciality = "AI" 29 | fmt.Println("Mark changed his speciality") 30 | fmt.Println("His speciality is ", mark.speciality) 31 | // modify age 32 | fmt.Println("Mark become old") 33 | mark.age = 46 34 | fmt.Println("His age is", mark.age) 35 | // modify weight 36 | fmt.Println("Mark is not an athlete any more") 37 | mark.weight += 60 38 | fmt.Println("His weight is", mark.weight) 39 | } 40 | -------------------------------------------------------------------------------- /ja/ebook/11.0.md: -------------------------------------------------------------------------------- 1 | # 11 エラー処理、デバッグとテスト 2 | 大部分のプログラマが"プログラム"を行う時間をbugの検査とbugの修正にかけています。あなたがコードを修正しているかシステムを再構築しているかに関わらず、ほとんどは大量の時間を故障の排除とテストに費やしています。外の世界は我々プログラマをデザイナだと思い込んでいます。システムをゼロから作り出すことができ、とても偉大で相当面白みのある仕事だと。しかし実際のところ我々は毎日エラーを取り除き、デバッグし、テストを行うことに終始しています。当然もしあなたに良い習慣があり、技術プランとこのような問題に直面しているとしたら、エラーを排除する時間を最小限に抑えて時間を価値のある事柄に費やそうとするかもしれません。 3 | 4 | しかし残念なことに多くのプログラマはエラーの処理、デバッグやテストに時間をかけたいとは思いません。結果、アプリケーションが実運用された後になってエラーを探し出し問題を特定することにより多くの時間を費やすことになります。そのため、我々はアプリケーションを設計する前にエラー処理のプランやテスト等を前もって準備します。将来コードを修正、システムをアップグレードするのが簡単になります。 5 | 6 | Webアプリケーションを開発するにあたって、エラーは避けられないものです。ではどのようにしてエラーの原因と問題の解決を探し出せばよいのでしょうか? 11.1節ではGo言語においてどのようにエラー処理を行い、自分のパッケージを設計して、関数のエラー処理を行うかご紹介します。11.2節ではGDBを使ってどのように我々のプログラムをデバッグするかご紹介します。動的に実行した状況かで各種変数の情報、実行状況の監視とデバッグ。 7 | 8 | 11.3節ではGo言語のユニットテストに対して深く見ていくことにします。どのようにしてユニットテストを書くのかやGoのユニットテストのルールをどのように定義するのかをご紹介し、今後アップグレードや修正に対応したテストコードが最小化されたテストを実行できるよう保証します。 9 | 10 | 長きにわたって、良好なデバッグ、テストの習慣を身につけるのは多くのプログラマが逃げてきた事柄です。ですから、もう逃げないでください。あなたの現在のプロジェクトの開発から。Go Web開発を学習することで良好な習慣を身につけてください。 11 | 12 | ## 目次 13 | 14 | ![](images/navi11.png?raw=true) 15 | 16 | ## links 17 | * [目次]() 18 | * 前へ: [第十章まとめ](<10.4.md>) 19 | * 次へ: [エラー処理](<11.1.md>) 20 | -------------------------------------------------------------------------------- /en/eBook/05.0.md: -------------------------------------------------------------------------------- 1 | # 5 Database 2 | 3 | For web developers, the database is at the core of web development. You can save almost anything into a database and query or update data inside it, like user information, products or news articles. 4 | 5 | Go doesn't provide any database drivers, but it does have a driver interface defined in the `database/sql` package. People can develop database drivers based on that interface. In section 5.1, we are going to talk about database driver interface design in Go; in sections 5.2 to 5.4, I will introduce some SQL database drivers to you; in section 5.5, i'll present the ORM that i've developed which is based on the `database/sql` interface standard. It's compatible with most drivers that have implemented the `database/sql` interface, and it makes it easy to access databases idiomatically in Go. 6 | 7 | NoSQL has been a hot topic in recent years. More websites are deciding to use NoSQL databases as their main database instead of just for the purpose of caching. I will introduce you to two NoSQL databases, which are MongoDB and Redis, in section 5.6. 8 | 9 | ## Links 10 | 11 | - [Directory](preface.md) 12 | - Previous Chapter: [Chapter 4 Summary](04.6.md) 13 | - Next section: [database/sql interface](05.1.md) 14 | -------------------------------------------------------------------------------- /en/eBook/12.0.md: -------------------------------------------------------------------------------- 1 | # 12 Deployment and maintenance 2 | 3 | So far, we have already described how to develop programs, debugger, and test procedures, as is often said: the development of the last 10% takes 90% of the time, so this chapter we will emphasize this last part of the 10% to truly become the most trusted and used by outstanding application, you need to consider some of the details of the above-mentioned 10% refers to these small details. 4 | 5 | In this chapter we will be four sections to introduce these small details of the deal, the first section describes how to program production services recorded on the log, how to logging, an error occurs a second section describes how to deal with our program, how to ensure as far as possible less impact to the user's access to, and the third section describes how to deploy Go standalone program, due to the current Go programs that can not be written as C daemon, then the process of how we manage the program running in the background so it? The fourth section describes the application of data backup and recovery, try to ensure that applications crash can maintain data integrity. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous chapter: [Chapter 11 summary](11.4.md) 11 | - Next section: [Logs](12.1.md) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.4/embedded_structs2/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.4 from "Build Web Application with Golang" 2 | // Purpose: Another example of embedded fields 3 | package main 4 | 5 | import "fmt" 6 | 7 | type Skills []string 8 | 9 | type Human struct { 10 | name string 11 | age int 12 | weight int 13 | } 14 | 15 | type Student struct { 16 | Human // struct as embedded field 17 | Skills // string slice as embedded field 18 | int // built-in type as embedded field 19 | speciality string 20 | } 21 | 22 | func main() { 23 | // initialize Student Jane 24 | jane := Student{Human: Human{"Jane", 35, 100}, speciality: "Biology"} 25 | // access fields 26 | fmt.Println("Her name is ", jane.name) 27 | fmt.Println("Her age is ", jane.age) 28 | fmt.Println("Her weight is ", jane.weight) 29 | fmt.Println("Her speciality is ", jane.speciality) 30 | // modify value of skill field 31 | jane.Skills = []string{"anatomy"} 32 | fmt.Println("Her skills are ", jane.Skills) 33 | fmt.Println("She acquired two new ones ") 34 | jane.Skills = append(jane.Skills, "physics", "golang") 35 | fmt.Println("Her skills now are ", jane.Skills) 36 | // modify embedded field 37 | jane.int = 3 38 | fmt.Println("Her preferred number is", jane.int) 39 | } 40 | -------------------------------------------------------------------------------- /en/eBook/12.5.md: -------------------------------------------------------------------------------- 1 | # 12.5 Summary 2 | 3 | This chapter discusses how to deploy and maintain Web applications we develop some related topics. The content is very important to be able to create a minimum maintenance based applications running smoothly, we must consider these issues. 4 | 5 | Specifically, the discussion in this chapter include: 6 | 7 | - Create a robust logging system that can record an error in case of problems and notify the system administrator 8 | - Handle runtime errors that may occur, including logging, and how to display to the user-friendly system there is a problem 9 | - Handling 404 errors, telling the user can not find the requested page 10 | - Deploy applications to a production environment (including how to deploy updates) 11 | - How to deploy highly available applications 12 | - Backup and restore files and databases 13 | 14 | After reading this chapter, for the development of a Web application from scratch, those issues need to be considered, you should already have a comprehensive understanding. This chapter will help you in the actual environment management in the preceding chapter describes the development of the code. 15 | 16 | ## Links 17 | 18 | - [Directory](preface.md) 19 | - Previous section: [Backup and recovery](12.4.md) 20 | - Next chapter: [Build a web framework](13.0.md) 21 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.3/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 4.3 from "Build Web Application with Golang" 2 | // Purpose: Shows how to properly escape input 3 | package main 4 | 5 | import ( 6 | "html/template" 7 | "net/http" 8 | textTemplate "text/template" 9 | ) 10 | 11 | var t *template.Template = template.Must(template.ParseFiles("index.gtpl")) 12 | 13 | func index(w http.ResponseWriter, r *http.Request) { 14 | r.ParseForm() 15 | userInput := r.Form.Get("userinput") 16 | if 0 < len(r.Form.Get("escape")) { 17 | t.Execute(w, template.HTMLEscapeString(userInput)) 18 | } else { 19 | // Variables with type `template.HTML` are not escaped when passed to `.Execute()` 20 | t.Execute(w, template.HTML(userInput)) 21 | } 22 | } 23 | func templateHandler(w http.ResponseWriter, r *http.Request) { 24 | r.ParseForm() 25 | userInput := r.Form.Get("userinput") 26 | if 0 < len(r.Form.Get("escape")) { 27 | // `html/template.Execute()` escapes input 28 | t.Execute(w, userInput) 29 | } else { 30 | tt := textTemplate.Must(textTemplate.ParseFiles("index.gtpl")) 31 | // `text/template.Execute()` doesn't escape input 32 | tt.Execute(w, userInput) 33 | } 34 | } 35 | func main() { 36 | http.HandleFunc("/", index) 37 | http.HandleFunc("/template", templateHandler) 38 | http.ListenAndServe(":9090", nil) 39 | } 40 | -------------------------------------------------------------------------------- /ja/ebook/10.0.md: -------------------------------------------------------------------------------- 1 | # 10 国際化とローカライズ 2 | 経済のグローバル化に対応する為、開発者として、多言語、国際化をサポートするWebアプリケーションを開発する必要があります。すなわち、同じページに異なる言語環境下で異なる効果を表示させる必要があります。つまりアプリケーションプログラムが実行される際リクエストの発信元の地域と言語の違いによって異なるユーザ・インターフェースを表示できなければなりません。このように、アプリケーション・プログラムにおいて新しい言語の追加をサポートする時、アプリケーションプログラムのコードの修正を必要とせずとも、言語パッケージを追加するだけで実現することができます。 3 | 4 | 国際化とローカライズ(Internationalization and localization,通常はi18nとL10Nによって表現されます)、国際化とは、ある地域に対してデザインされたプログラムを再構築するということです。それによりその他の多くの地域でも使用できるようにします。ローカライズとは国際化を睨んだプログラムにおいて新しい地域に対するサポートを追加することを指します。 5 | 6 | 現在、Go言語の標準パッケージではi18nのサポートは提供されておりません。しかし、比較的簡単なサードパーティの実装があります。この章ではgo-i18nライブラリを実装し、Go言語のi18nをサポートすることにします。 7 | 8 | いわゆる国際化とは:特定のlocal情報に従って、これに対応する文字列またはそのたの物(たとえば時間や通貨のフォーマットです)を取り出すといったことです。これには3つの問題があります: 9 | 10 | 1、どのようにしてlocaleを確定するのか。 11 | 12 | 2、どのようにしてlocaleに対応した文字列またはその他の情報を保存するのか。 13 | 14 | 3、どのようにしてlocaleに沿って文字列とその他対応する情報を取り出すのか。 15 | 16 | この節ではどのようにして正しいlocaleを設定し、アクセスしたサイトのユーザにその言語に対応するページを取得させるようにできるかをご紹介します。第二節ではどのようにして文字列、通貨、日時といったlocaleに対応した情報を処理または保存するのかについてご紹介します。第三節ではサイトの国際化をどのように実現するのかについてご紹介します。すなわち、どのようにして異なるlocaleに対してふさわしいコンテンツを返すかということです。この3つの節を学習することで、完全なi18nソリューションを得ることができます。 17 | 18 | ## 目次 19 | 20 | ![](images/navi10.png?raw=true) 21 | 22 | ## links 23 | * [目次]() 24 | * 前へ: [第九章まとめ](<09.7.md>) 25 | * 次へ: [デフォルトロケールの設定](<10.1.md>) 26 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.4/compare_age/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 2.4 from "Build Web Application with Golang" 2 | // Purpose: Shows you how to pass and use structs. 3 | package main 4 | 5 | import "fmt" 6 | 7 | // define a new type 8 | type person struct { 9 | name string 10 | age int 11 | } 12 | 13 | // compare age of two people, return the older person and differences of age 14 | // struct is passed by value 15 | func Older(p1, p2 person) (person, int) { 16 | if p1.age > p2.age { 17 | return p1, p1.age - p2.age 18 | } 19 | return p2, p2.age - p1.age 20 | } 21 | 22 | func main() { 23 | var tom person 24 | 25 | // initialization 26 | tom.name, tom.age = "Tom", 18 27 | 28 | // initialize two values by format "field:value" 29 | bob := person{age: 25, name: "Bob"} 30 | 31 | // initialize two values with order 32 | paul := person{"Paul", 43} 33 | 34 | tb_Older, tb_diff := Older(tom, bob) 35 | tp_Older, tp_diff := Older(tom, paul) 36 | bp_Older, bp_diff := Older(bob, paul) 37 | 38 | fmt.Printf("Of %s and %s, %s is older by %d years\n", tom.name, bob.name, tb_Older.name, tb_diff) 39 | 40 | fmt.Printf("Of %s and %s, %s is older by %d years\n", tom.name, paul.name, tp_Older.name, tp_diff) 41 | 42 | fmt.Printf("Of %s and %s, %s is older by %d years\n", bob.name, paul.name, bp_Older.name, bp_diff) 43 | } 44 | -------------------------------------------------------------------------------- /en/eBook/06.0.md: -------------------------------------------------------------------------------- 1 | # 6 Data storage and sessions 2 | 3 | An important topic in web development is providing a good user experience, but the fact that HTTP is a stateless protocol seems contrary to this spirit. How can we control the whole process of viewing websites for users? The classic solutions are using cookies and sessions, where cookies serve as the client side mechanism and sessions are saved on the server side with a unique identifier for every single user. Note that sessions can be passed in URLs or cookies, or even in your database (which is much more secure, but may hamper your application performance). 4 | 5 | In section 6.1, we are going to talk about differences between cookies and sessions. In section 6.2, you'll learn how to use sessions in Go with an implementation of a session manager. In section 6.3, we will talk about session hijacking and how to prevent it when you know that sessions can be saved anywhere. The session manager we will implement in section 6.3 will save sessions in memory, but if we need to expand our application to allow for session sharing, it's always better to save these sessions directly into our database. We'll talk more about this in section 6.4. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous Chapter: [Chapter 5 Summary](05.7.md) 11 | - Next section: [Session and cookies](06.1.md) 12 | -------------------------------------------------------------------------------- /en/eBook/08.5.md: -------------------------------------------------------------------------------- 1 | # 8.5 Summary 2 | 3 | In this chapter, I introduced you to several mainstream web application development models. In section 8.1, I described the basics of network programming sockets. Because of the rapid evolution of network technology and infrastructure, and given that the Socket is the cornerstone of these changes, you must master the concepts behind socket programming in order to be a competent web developer. In section 8.2, I described HTML5 WebSockets which support full-duplex communications between client and server and eliminate the need for polling with AJAX. In section 8.3, we implemented a simple application using the REST architecture, which is particularly suitable for the development of network APIs; due to the rapid rise of mobile applications, I believe that RESTful APIs will be an ongoing trend. In section 8.4, we learned about Go RPCs. 4 | 5 | Go provides excellent support for the four kinds of development methods mentioned above. Note that the `net` package and its sub-packages is the place where Go's network programming tools Go reside. If you want a more in-depth understanding of the relevant implementation details, you should try reading the source code of those packages. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous section: [RPC](08.4.md) 11 | - Next chapter: [Security and encryption](09.0.md) 12 | -------------------------------------------------------------------------------- /ja/ebook/08.0.md: -------------------------------------------------------------------------------- 1 | # 8 Webサービス 2 | WebサービスではHTTPプロトコルの基礎の上にXMLまたはJSONを使って情報を交換することができるようになります。もし上海の天気予報やチャイナペトロの株価やタオバオの商店にある商品の情報を知りたいとすると、簡単なコードを少し書くことでこれらの情報を標準的なオープンインターフェースを介して取得することができます。ローカルで関数をコールすると値をひとつ返すのと同じようなものです。 3 | 4 | Webサービスのバックエンドのキーはプラットフォームに依存しないことです。あなたはあなたのサービスをLinuxシステムで実行してもかまいませんし、他のWindowsのasp.netプログラムと交互に同様に一つのインターフェースを通じてFreeBSD上で実行されているJSPとなんの障害も無く通信することもできます。 5 | 6 | 現在主流となっているのは以下のいくつかのWebサービスです:REST、SOAP。 7 | 8 | RESTリクエストはとても直感的です。なぜならRESTはHTTPプロトコルに基いた追加だからです。各リクエストはどれもHTTPリクエストです。異なるmethodに従って異なるロジックを処理します。多くのWeb開発者はいずれもHTTPプロトコルに詳しいので、RESTを学ぶことは比較的簡単でしょう。ですので我々は8.3節においてどのようにGo言語でRESTメソッドを実装するか詳細にご紹介します。 9 | 10 | SOAPはW3Cのネットワークを超えた情報伝達とリモートコンピュータの関数呼び出し規約の標準のひとつです。しかしSOAPはとても複雑で、完全な規則は非常に長くなります。また内容はいまでも増加しています。Go言語は簡単さで有名ですのでSOAPのような複雑なものはここではご紹介しません。Go言語は生まれながらにしてとても良い、開発に便利なRPCメカニズムを提供しています。8.4節ではどのようにしてGo言語を使ってRPCを実装するか詳しくご紹介するつもりです。 11 | 12 | Go言語は21世紀のC言語です。性能と簡単さを追求するため、8.1節ではどのようにしてSocketプログラミングを行うかご説明します。多くのゲームサービスはどれもSocketを採用してサーバをプログラムしています。HTTPプロトコルは比較的性能を必要とするものですので、Go言語がどのようにしてSocketプログラミングを行うのか見てみることにしましょう。現在HTML5の発展にしたがって、WebSocketも多くのゲーム会社が引き続き開発する手段の一つとなりつつあります。8.2節ではGo言語でどのようにしてWebSocketのコードをプログラムするかご説明します。 13 | 14 | ## 目次 15 | ![](images/navi8.png?raw=true) 16 | 17 | ## links 18 | * [目次]() 19 | * 次へ: [第七章まとめ](<07.7.md>) 20 | * 前へ: [Socketプログラミング](<08.1.md>) 21 | -------------------------------------------------------------------------------- /en/eBook/07.0.md: -------------------------------------------------------------------------------- 1 | # 7 Text files 2 | 3 | Handling text files is a big part of web development. We often need to produce or handle received text content, including strings, numbers, JSON, XML, etc. As a high performance language, Go has good support for this in its standard library. You'll find that these supporting libraries are just awesome, and will allow you to easily deal with any text content you may encounter. This chapter contains 4 sections, and will give you a full introduction to text processing in Go. 4 | 5 | XML is an interactive language that is commonly used in many APIs, many web servers written in Java use XML as their standard interaction language. We'll more talk about XML in section 7.1. In section 7.2, we'll take a look at JSON which has been very popular in recent years and is much more convenient than XML. In section 7.3, we are going to talk about regular expressions which (for the majority of people) looks like a language used by aliens. In section 7.4, you will see how the MVC pattern is used to develop applications in Go, and also how to use Go's `template` package for templating your views. In section 7.5, we'll introduce you to file and folder operations. Finally, we will explain some Go string operations in section 7.6. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous Chapter: [Chapter 6 Summary](06.5.md) 11 | - Next section: [XML](07.1.md) 12 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.6/mongodb/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 5.6 from "Build Web Application with Golang" 2 | // Purpose: Shows you have to perform basic CRUD operations for a mongodb driver. 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "labix.org/v2/mgo" 8 | "labix.org/v2/mgo/bson" 9 | ) 10 | 11 | type Person struct { 12 | Name string 13 | Phone string 14 | } 15 | 16 | func checkError(err error) { 17 | if err != nil { 18 | panic(err) 19 | } 20 | } 21 | 22 | const ( 23 | DB_NAME = "test" 24 | DB_COLLECTION = "people" 25 | ) 26 | 27 | func main() { 28 | session, err := mgo.Dial("localhost") 29 | checkError(err) 30 | defer session.Close() 31 | 32 | session.SetMode(mgo.Monotonic, true) 33 | 34 | c := session.DB(DB_NAME).C(DB_COLLECTION) 35 | err = c.DropCollection() 36 | checkError(err) 37 | 38 | ale := Person{"Ale", "555-5555"} 39 | cla := Person{"Cla", "555-1234"} 40 | 41 | fmt.Println("Inserting") 42 | err = c.Insert(&ale, &cla) 43 | checkError(err) 44 | 45 | fmt.Println("Updating") 46 | ale.Phone = "555-0101" 47 | err = c.Update(bson.M{"name": "Ale"}, &ale) 48 | 49 | fmt.Println("Querying") 50 | result := Person{} 51 | err = c.Find(bson.M{"name": "Ale"}).One(&result) 52 | checkError(err) 53 | fmt.Println("Phone:", result.Phone) 54 | 55 | fmt.Println("Deleting") 56 | err = c.Remove(bson.M{"name": "Ale"}) 57 | checkError(err) 58 | } 59 | -------------------------------------------------------------------------------- /ja/ebook/09.0.md: -------------------------------------------------------------------------------- 1 | # 9 セキュリティと暗号化 2 | Webアプリケーションの開発者にとっても、Webアプリケーションのセキュリティホールの攻撃者も、Webアプリケーションのセキュリティという話題に対してはますます熱い視線を送っています。特に最近のCSDNのパスワード漏洩事件によって我々はWebセキュリティという話題により注視するようになっています。パスワードの話をするとみんな顔色が変わります。みんな自分のシステムにセキュリティホールがないか検査し始めました。Goプログラムの開発者として、我々のアプリケーション・プログラムがいつでも大多数の攻撃者の目標となりうることを知っておかなければなりません。前もって防御する準備を整えておかなければなりません。 3 | 4 | Webアプリケーションプログラムのセキュリティ問題の理由の多くは軽々しく第三者からもたらされたデータを信じてしまうことにあります。例えばユーザの入力したデータに対して、これに対し検証を行う前はすべて安全ではないデータであるとみなさなければなりません。もしこれらの安全ではないデータをクライアントに出力すると、クロスサイトスクリプティング(XSS)の問題を引き起こしかねません。もし安全ではないデータをデータベースの検索に使用すると、SQLインジェクションの問題を引き起こす可能性があります。我々は9.3、9.4節においてどのようにこれらの問題を避けるかについてご紹介します。 5 | 6 | ユーザの提供するデータなど第三者が提供したデータを使用する際、まずこれらのデータの合法性を検証することは非常に重要です。これらのプロセスをフィルタリングと呼びます。9.2節においてどのようにすべてのデータに対してフィルタリングを行うかご紹介します。 7 | 8 | 入力のフィルタリングと出力のエスケープはすべての問題を解決するわけではありません。9.1節でCSRFアタックについてご紹介します。ターゲットが攻撃者の指定するリクエストを送ってしまうことで破壊を発生させる可能性があります。 9 | 10 | セキュリティ暗号化では、我々のWebアプリケーションプログラムを強化できる強力な手段が暗号化です。CSDN漏洩事件はパスワードを平文で保存していたことによるものです。攻撃者がデータベースを取得した後直接いくつかの破壊行為が実施できてしまいました。しかし、他のツールと同じく暗号化手段もしっかりしていなければなりません。9.5節ではどのようにパスワードを保存し、パスワードを安全に保存するかご紹介します。 11 | 12 | 暗号化の本質はデータをかき乱すことにあります。ある逆算不可能なデータの撹拌を単方向暗号化もしくはハッシュアルゴリズムと呼びます。また双方向の暗号化方式もあります。暗号化したデータを逆に復号することができます。9.6節でどのようにしてこのような双方向の暗号化方式を実現するかご紹介します。 13 | 14 | ## 目次 15 | ![](images/navi9.png?raw=true) 16 | 17 | ## links 18 | * [目次]() 19 | * 前へ: [第八章まとめ](<08.5.md>) 20 | * 次へ: [CSRF攻撃の予防](<09.1.md>) 21 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.5.6/redis/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 5.6 from "Build Web Application with Golang" 2 | // Purpose: Shows you have to perform basic CRUD operations for a redis driver. 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "github.com/astaxie/goredis" 8 | ) 9 | 10 | func checkError(err error) { 11 | if err != nil { 12 | panic(err) 13 | } 14 | } 15 | 16 | const ( 17 | DB_PORT = "9191" 18 | DB_URL = "127.0.0.1" 19 | ) 20 | 21 | func main() { 22 | var client goredis.Client 23 | 24 | // Set the default port in Redis 25 | client.Addr = DB_URL + ":" + DB_PORT 26 | 27 | // string manipulation 28 | fmt.Println("Inserting") 29 | err := client.Set("a", []byte("hello")) 30 | checkError(err) 31 | 32 | // list operation 33 | vals := []string{"a", "b", "c", "d"} 34 | for _, v := range vals { 35 | err = client.Rpush("l", []byte(v)) 36 | checkError(err) 37 | } 38 | fmt.Println("Updating") 39 | err = client.Set("a", []byte("a is for apple")) 40 | checkError(err) 41 | err = client.Rpush("l", []byte("e")) 42 | checkError(err) 43 | 44 | fmt.Println("Querying") 45 | val, err := client.Get("a") 46 | checkError(err) 47 | fmt.Println(string(val)) 48 | 49 | dbvals, err := client.Lrange("l", 0, 4) 50 | checkError(err) 51 | for i, v := range dbvals { 52 | println(i, ":", string(v)) 53 | } 54 | 55 | fmt.Println("Deleting") 56 | _, err = client.Del("l") 57 | checkError(err) 58 | _, err = client.Del("a") 59 | checkError(err) 60 | } 61 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, AstaXie and The Contributors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the AstaXie nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /en/eBook/14.0.md: -------------------------------------------------------------------------------- 1 | # 14 Develop web framework 2 | 3 | Chapter XIII describes how to develop a Web framework, by introducing the MVC, routing, log processing, the configuration process is completed a basic framework for the system, but a good framework requires some auxiliary tools to facilitate rapid development of Web, then we this chapter will provide some quick how to develop Web-based tools are introduced, the first section explains how to deal with static files, how to use existing open source twitter bootstrap for rapid development of beautiful sites, the second section describes how to use the previously described the session for user log in process, and the third section describes how convenient output forms that how data validation, how fast the data binding model for CRUD operations, the fourth section describes how to perform some user authentication, including http basic certification, http digest authentication, the fifth section describes how to use the previously described i18n support multi-language application development. 4 | 5 | In this chapter expansion, beego framework will have rapid development of Web properties, and finally we will explain how to use the features of these extensions extension development blog system developed in Chapter XIII, through the development of a complete, beautiful blog system allows readers to understand beego development brings you fast. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous chapter: [Chapter 13 summary](13.6.md) 11 | - Next section: [Static files](14.1.md) 12 | -------------------------------------------------------------------------------- /en/eBook/09.7.md: -------------------------------------------------------------------------------- 1 | # 9.7 Summary 2 | 3 | In this chapter, we've described CSRF, XSS and SQL injection based attacks. Most web applications are vulnerable to these types of attacks due to a lack of adequate input filtering on the part of the application. So, in addition to introducing the principles behind these attacks, we've also introduced a few techniques for effectively filtering user data and preventing these attacks from ever taking place. We then talked about a few methods for securely storing user passwords, first introducing basic one-way hashing for web applications with loose security requirements, then password salting and encryption algorithms for more serious applications. Finally, we briefly discussed two-way hashing and the encryption and decryption of sensitive data. We learned that the Go language provides packages for three symmetric encryption algorithms: base64, AES and DES. 4 | The purpose of this chapter is to help readers become more conscious of the security issues that exist in modern day web applications. Hopefully, it can help developers to plan and design their web applications a little more carefully, so they can write systems that are able to prevent hackers from exploiting user data. The Go language has a large and well designed anti-attack toolkit, and every Go developer should take full advantage of these packages to better secure their web applications. 5 | 6 | ## Links 7 | 8 | - [Directory](preface.md) 9 | - Previous section: [Encrypt and decrypt data](09.6.md) 10 | - Next chapter: [Internationalization and localization](10.0.md) 11 | -------------------------------------------------------------------------------- /en/eBook/02.8.md: -------------------------------------------------------------------------------- 1 | # 2.8 Summary 2 | 3 | In this chapter, we mainly introduced the 25 Go keywords. Let's review what they are and what they do. 4 | 5 | break default func interface select 6 | case defer go map struct 7 | chan else goto package switch 8 | const fallthrough if range type 9 | continue for import return var 10 | 11 | - `var` and `const` are used to define variables and constants. 12 | - `package` and `import` are for package use. 13 | - `func` is used to define functions and methods. 14 | - `return` is used to return values in functions or methods. 15 | - `defer` is used to define defer functions. 16 | - `go` is used to start a new goroutine. 17 | - `select` is used to switch over multiple channels for communication. 18 | - `interface` is used to define interfaces. 19 | - `struct` is used to define special customized types. 20 | - `break`, `case`, `continue`, `for`, `fallthrough`, `else`, `if`, `switch`, `goto` and `default` were introduced in section 2.3. 21 | - `chan` is the type of channel for communication among goroutines. 22 | - `type` is used to define customized types. 23 | - `map` is used to define map which is similar to hash tables in other languages. 24 | - `range` is used for reading data from `slice`, `map` and `channel`. 25 | 26 | If you understand how to use these 25 keywords, you've learned a lot of Go already. 27 | 28 | ## Links 29 | 30 | - [Directory](preface.md) 31 | - Previous section: [Concurrency](02.7.md) 32 | - Next chapter: [Web foundation](03.0.md) 33 | -------------------------------------------------------------------------------- /en/eBook/01.0.md: -------------------------------------------------------------------------------- 1 | # 1 Go Environment Configuration 2 | 3 | Welcome to the world of Go, let's start exploring! 4 | 5 | Go is a fast-compiled, garbage-collected, concurrent systems programming language. It has the following advantages: 6 | 7 | - Compiles a large project within a few seconds. 8 | - Provides a software development model that is easy to reason about, avoiding most of the problems associated with C-style header files. 9 | - Is a static language that does not have levels in its type system, so users do not need to spend much time dealing with relations between types. It is more like a lightweight object-oriented language. 10 | - Performs garbage collection. It provides basic support for concurrency and communication. 11 | - Designed for multi-core computers. 12 | 13 | Go is a compiled language. It combines the development efficiency of interpreted or dynamic languages with the security of static languages. It is going to be the language of choice for modern, multi-core computers with networking. For these purposes, there are some problems that need to inherently be resolved at the level of the language of choice, such as a richly expressive lightweight type system, a native concurrency model, and strictly regulated garbage collection. For quite some time, no packages or tools have emerged that have aimed to solve all of these problems in a pragmatic fashion; thus was born the motivation for the Go language. 14 | 15 | In this chapter, I will show you how to install and configure your own Go development environment. 16 | 17 | ## Links 18 | 19 | - [Directory](preface.md) 20 | - Next section: [Installation](01.1.md) 21 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.1/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 4.1 from "Build Web Application with Golang" 2 | // Purpose: Shows how to create a simple login using a template 3 | // Run: `go run main.go`, then access `http://localhost:9090` and `http://localhost:9090/login` 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "html/template" 9 | "log" 10 | "net/http" 11 | "strings" 12 | ) 13 | 14 | func sayhelloName(w http.ResponseWriter, r *http.Request) { 15 | r.ParseForm() //Parse url parameters passed, then parse the response packet for the POST body (request body) 16 | // attention: If you do not call ParseForm method, the following data can not be obtained form 17 | fmt.Println(r.Form) // print information on server side. 18 | fmt.Println("path", r.URL.Path) 19 | fmt.Println("scheme", r.URL.Scheme) 20 | fmt.Println(r.Form["url_long"]) 21 | for k, v := range r.Form { 22 | fmt.Println("key:", k) 23 | fmt.Println("val:", strings.Join(v, "")) 24 | } 25 | fmt.Fprintf(w, "Hello astaxie!") // write data to response 26 | } 27 | 28 | func login(w http.ResponseWriter, r *http.Request) { 29 | fmt.Println("method:", r.Method) //get request method 30 | if r.Method == "GET" { 31 | t, _ := template.ParseFiles("login.gtpl") 32 | t.Execute(w, nil) 33 | } else { 34 | r.ParseForm() 35 | // logic part of log in 36 | fmt.Println("username:", r.Form["username"]) 37 | fmt.Println("password:", r.Form["password"]) 38 | } 39 | } 40 | 41 | func main() { 42 | http.HandleFunc("/", sayhelloName) // setting router rule 43 | http.HandleFunc("/login", login) 44 | err := http.ListenAndServe(":9090", nil) // setting listening port 45 | if err != nil { 46 | log.Fatal("ListenAndServe: ", err) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ebook/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SED='sed' 4 | 5 | if [ `uname -s` == 'Darwin' ] ; then 6 | SED='gsed' 7 | fi 8 | 9 | bn="`basename $0`" 10 | WORKDIR="$(cd $(dirname $0); pwd -P)" 11 | 12 | # 13 | # Default language: zh 14 | # You can overwrite following variables in config file. 15 | # 16 | MSG_INSTALL_PANDOC_FIRST='请先安装pandoc,然后再次运行' 17 | MSG_SUCCESSFULLY_GENERATED='build-web-application-with-golang.epub 已经建立' 18 | MSG_CREATOR='Astaxie' 19 | MSG_DESCRIPTION='一本开源的Go Web编程书籍' 20 | MSG_LANGUAGE='zh-CN' 21 | MSG_TITLE='Go Web编程' 22 | [ -e "$WORKDIR/config" ] && . "$WORKDIR/config" 23 | 24 | 25 | TMP=`mktemp -d 2>/dev/null || mktemp -d -t "${bn}"` || exit 1 26 | trap 'rm -rf "$TMP"' 0 1 2 3 15 27 | 28 | 29 | cd "$TMP" 30 | 31 | ( 32 | [ go list github.com/fairlyblank/md2min >/dev/null 2>&1 ] || export GOPATH="$PWD" 33 | go get -u github.com/fairlyblank/md2min 34 | WORKDIR="$WORKDIR" TMP="$TMP" go run "$WORKDIR/build.go" 35 | ) 36 | 37 | if [ ! type -P pandoc >/dev/null 2>&1 ]; then 38 | echo "$MSG_INSTALL_PANDOC_FIRST" 39 | exit 0 40 | fi 41 | 42 | cat <<__METADATA__ > metadata.txt 43 | $MSG_CREATOR 44 | $MSG_DESCRIPTION 45 | $MSG_LANGUAGE 46 | Creative Commons 47 | $MSG_TITLE 48 | __METADATA__ 49 | 50 | mkdir -p $TMP/images 51 | cp -r $WORKDIR/images/* $TMP/images/ 52 | ls [0-9]*.html | xargs $SED -i "s/png?raw=true/png/g" 53 | 54 | pandoc --reference-links -S --toc -f html -t epub --epub-metadata=metadata.txt --epub-cover-image="$WORKDIR/images/cover.png" -o "$WORKDIR/../build-web-application-with-golang.epub" `ls [0-9]*.html | sort` 55 | 56 | echo "$MSG_SUCCESSFULLY_GENERATED" 57 | -------------------------------------------------------------------------------- /ja/glossary.md: -------------------------------------------------------------------------------- 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 | ## 讲解 32 | 解説 33 | 34 | ## 嗅探 35 | スニッフィング 36 | 37 | ## 劫持 38 | ハイジャック 39 | 40 | ## 领略 41 | 味わう 42 | 43 | ## 数据交换语言 44 | データ記述言語 45 | 46 | ## 内建 47 | ビルトイン 48 | 49 | ## 运维 50 | 操作 51 | 52 | ## 嵌套 53 | ネストした 54 | 55 | ## 死循环 56 | 永久ループ 57 | 58 | ## 模式匹配 59 | パターンマッチ 60 | 61 | ## 筛选 62 | フィルターする 63 | 64 | ## 展现 65 | 表示 66 | 67 | ## 上下文 68 | コンテキスト 69 | 70 | ## 注入 71 | インジェクション 72 | 73 | ## 文件描述符 74 | ファイルディスクリプタ 75 | 76 | ## 打开的方式 77 | オープンモード 78 | 79 | ## 以一斑窥全豹 80 | ひとつを見てすべてを理解する 81 | 82 | ## 数据报 83 | データグラム 84 | 85 | ## 套接字 86 | ソケット 87 | 88 | ## 蓬勃 89 | 力強い 90 | 91 | ## 一劳永逸 92 | 一度苦労しておけば末永く楽できる 93 | 94 | ## 全双工通信 95 | 全二重通信 96 | 97 | ## 轮询 98 | ポーリング 99 | 100 | ## 带宽 101 | 帯域幅 102 | 103 | ## 句柄 104 | 扱う、ハンドル 105 | 106 | ## 异步 107 | 非同期 108 | 109 | ## 组件 110 | モジュール 111 | 112 | ## 掐头去尾 113 | 大事なところを残してあとは取り除く 114 | 115 | ## 约束条件 116 | 制約条件 117 | 118 | ## 阻塞型 119 | ブロッキング型 120 | 121 | ## 转义 122 | エスケープ 123 | 124 | ## 社会工程学 125 | ソーシャルエンジニアリング 126 | 127 | ## 殊不知 128 | 意外にも 129 | 130 | ## 层出不穷 131 | 尽きることのない 132 | 133 | ## 摘要 134 | ダイジェスト 135 | 136 | ## 聚合变量 137 | 集成体型変数 138 | 139 | ## 涵盖 140 | カバー 141 | 142 | ## 部署 143 | デプロイ 144 | 145 | ## 集群环境 146 | クラスタ環境 147 | 148 | ## 保留字 149 | キーワード 150 | 151 | ## 破折号 152 | ダッシュ 153 | 154 | ## 换行 155 | 改行 156 | 157 | ## 标签 158 | タグ 159 | 160 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.4/main.go: -------------------------------------------------------------------------------- 1 | // Example code for Chapter 3.2 from "Build Web Application with Golang" 2 | // Purpose: Shows how to prevent duplicate submissions by using tokens 3 | // Example code for Chapter 4.4 based off the code from Chapter 4.2 4 | // Run `go run main.go` then access http://localhost:9090 5 | package main 6 | 7 | import ( 8 | "apps/ch.4.4/nonce" 9 | "apps/ch.4.4/validator" 10 | "html/template" 11 | "log" 12 | "net/http" 13 | ) 14 | 15 | const ( 16 | PORT = "9090" 17 | HOST_URL = "http://localhost:" + PORT 18 | ) 19 | 20 | var submissions nonce.Nonces 21 | var t *template.Template 22 | 23 | func index(w http.ResponseWriter, r *http.Request) { 24 | http.Redirect(w, r, HOST_URL+"/profile", http.StatusTemporaryRedirect) 25 | } 26 | func profileHandler(w http.ResponseWriter, r *http.Request) { 27 | t.ExecuteTemplate(w, "profile", submissions.NewNonce()) 28 | } 29 | func checkProfile(w http.ResponseWriter, r *http.Request) { 30 | var errs validator.Errors 31 | r.ParseForm() 32 | token := r.Form.Get("token") 33 | if err := submissions.CheckThenMarkToken(token); err != nil { 34 | errs = validator.Errors{[]error{err}} 35 | } else { 36 | p := validator.ProfilePage{&r.Form} 37 | errs = p.GetErrors() 38 | } 39 | t.ExecuteTemplate(w, "submission", errs) 40 | } 41 | func init() { 42 | submissions = nonce.New() 43 | t = template.Must(template.ParseFiles("profile.gtpl", "submission.gtpl")) 44 | } 45 | func main() { 46 | http.HandleFunc("/", index) 47 | http.HandleFunc("/profile", profileHandler) 48 | http.HandleFunc("/checkprofile", checkProfile) 49 | 50 | err := http.ListenAndServe(":"+PORT, nil) // setting listening port 51 | if err != nil { 52 | log.Fatal("ListenAndServe: ", err) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.4/nonce/main.go: -------------------------------------------------------------------------------- 1 | // A nonce is a number or string used only once. 2 | // This is useful for generating a unique token for login pages to prevent duplicate submissions. 3 | package nonce 4 | 5 | import ( 6 | "crypto/md5" 7 | "errors" 8 | "fmt" 9 | "io" 10 | "math/rand" 11 | "strconv" 12 | "time" 13 | ) 14 | 15 | // Contains a unique token 16 | type Nonce struct { 17 | Token string 18 | } 19 | 20 | // Keeps track of marked/used tokens 21 | type Nonces struct { 22 | hashs map[string]bool 23 | } 24 | 25 | func New() Nonces { 26 | return Nonces{make(map[string]bool)} 27 | } 28 | func (n *Nonces) NewNonce() Nonce { 29 | return Nonce{n.NewToken()} 30 | } 31 | 32 | // Returns a new unique token 33 | func (n *Nonces) NewToken() string { 34 | t := createToken() 35 | for n.HasToken(t) { 36 | t = createToken() 37 | } 38 | return t 39 | } 40 | 41 | // Checks if token has been marked. 42 | func (n *Nonces) HasToken(token string) bool { 43 | return n.hashs[token] == true 44 | } 45 | func (n *Nonces) MarkToken(token string) { 46 | n.hashs[token] = true 47 | } 48 | func (n *Nonces) CheckToken(token string) error { 49 | if token == "" { 50 | return errors.New("No token supplied") 51 | } 52 | if n.HasToken(token) { 53 | return errors.New("Duplicate submission.") 54 | } 55 | return nil 56 | } 57 | func (n *Nonces) CheckThenMarkToken(token string) error { 58 | defer n.MarkToken(token) 59 | if err := n.CheckToken(token); err != nil { 60 | return err 61 | } 62 | return nil 63 | } 64 | func createToken() string { 65 | h := md5.New() 66 | now := time.Now().Unix() 67 | io.WriteString(h, strconv.FormatInt(now, 10)) 68 | io.WriteString(h, strconv.FormatInt(rand.Int63(), 10)) 69 | return fmt.Sprintf("%x", h.Sum(nil)) 70 | } 71 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.4.5/nonce/main.go: -------------------------------------------------------------------------------- 1 | // A nonce is a number or string used only once. 2 | // This is useful for generating a unique token for login pages to prevent duplicate submissions. 3 | package nonce 4 | 5 | import ( 6 | "crypto/md5" 7 | "errors" 8 | "fmt" 9 | "io" 10 | "math/rand" 11 | "strconv" 12 | "time" 13 | ) 14 | 15 | // Contains a unique token 16 | type Nonce struct { 17 | Token string 18 | } 19 | 20 | // Keeps track of marked/used tokens 21 | type Nonces struct { 22 | hashs map[string]bool 23 | } 24 | 25 | func New() Nonces { 26 | return Nonces{make(map[string]bool)} 27 | } 28 | func (n *Nonces) NewNonce() Nonce { 29 | return Nonce{n.NewToken()} 30 | } 31 | 32 | // Returns a new unique token 33 | func (n *Nonces) NewToken() string { 34 | t := createToken() 35 | for n.HasToken(t) { 36 | t = createToken() 37 | } 38 | return t 39 | } 40 | 41 | // Checks if token has been marked. 42 | func (n *Nonces) HasToken(token string) bool { 43 | return n.hashs[token] == true 44 | } 45 | func (n *Nonces) MarkToken(token string) { 46 | n.hashs[token] = true 47 | } 48 | func (n *Nonces) CheckToken(token string) error { 49 | if token == "" { 50 | return errors.New("No token supplied") 51 | } 52 | if n.HasToken(token) { 53 | return errors.New("Duplicate submission.") 54 | } 55 | return nil 56 | } 57 | func (n *Nonces) CheckThenMarkToken(token string) error { 58 | defer n.MarkToken(token) 59 | if err := n.CheckToken(token); err != nil { 60 | return err 61 | } 62 | return nil 63 | } 64 | func createToken() string { 65 | h := md5.New() 66 | now := time.Now().Unix() 67 | io.WriteString(h, strconv.FormatInt(now, 10)) 68 | io.WriteString(h, strconv.FormatInt(rand.Int63(), 10)) 69 | return fmt.Sprintf("%x", h.Sum(nil)) 70 | } 71 | -------------------------------------------------------------------------------- /en/code/src/apps/ch.2.5/box_example/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const ( 6 | WHITE = iota 7 | BLACK 8 | BLUE 9 | RED 10 | YELLOW 11 | ) 12 | 13 | type Color byte 14 | 15 | type Box struct { 16 | width, height, depth float64 17 | color Color 18 | } 19 | 20 | type BoxList []Box //a slice of boxes 21 | 22 | func (b Box) Volume() float64 { 23 | return b.width * b.height * b.depth 24 | } 25 | 26 | func (b *Box) SetColor(c Color) { 27 | b.color = c 28 | } 29 | 30 | func (bl BoxList) BiggestsColor() Color { 31 | v := 0.00 32 | k := Color(WHITE) 33 | for _, b := range bl { 34 | if b.Volume() > v { 35 | v = b.Volume() 36 | k = b.color 37 | } 38 | } 39 | return k 40 | } 41 | 42 | func (bl BoxList) PaintItBlack() { 43 | for i, _ := range bl { 44 | bl[i].SetColor(BLACK) 45 | } 46 | } 47 | 48 | func (c Color) String() string { 49 | strings := []string{"WHITE", "BLACK", "BLUE", "RED", "YELLOW"} 50 | return strings[c] 51 | } 52 | 53 | func main() { 54 | boxes := BoxList{ 55 | Box{4, 4, 4, RED}, 56 | Box{10, 10, 1, YELLOW}, 57 | Box{1, 1, 20, BLACK}, 58 | Box{10, 10, 1, BLUE}, 59 | Box{10, 30, 1, WHITE}, 60 | Box{20, 20, 20, YELLOW}, 61 | } 62 | 63 | fmt.Printf("We have %d boxes in our set\n", len(boxes)) 64 | fmt.Println("The volume of the first one is", boxes[0].Volume(), "cm³") 65 | fmt.Println("The color of the last one is", boxes[len(boxes)-1].color.String()) 66 | fmt.Println("The biggest one is", boxes.BiggestsColor().String()) 67 | 68 | fmt.Println("Let's paint them all black") 69 | boxes.PaintItBlack() 70 | fmt.Println("The color of the second one is", boxes[1].color.String()) 71 | 72 | fmt.Println("Obviously, now, the biggest one is", boxes.BiggestsColor().String()) 73 | } 74 | -------------------------------------------------------------------------------- /en/eBook/04.0.md: -------------------------------------------------------------------------------- 1 | # 4 User form 2 | 3 | A user form is something that is very commonly used when developping web applications. It provides the ability to communicate between clients and servers. You must be very familiar with forms if you are a web developer; if you are a C/C++ programmer, you may want to ask: what is a user form? 4 | 5 | A form is an area that contains form elements. Users can input information into form elements like text boxes, drop down lists, radio buttons, check boxes, etc. We use the form tag `
` to define forms. 6 | 7 | 8 | ... 9 | input elements 10 | ... 11 |
12 | 13 | Go already has many convenient functions to deal with user forms. You can easily get form data in HTTP requests, and they are easy to integrate into your own web applications. In section 4.1, we are going to talk about how to handle form data in Go. Also, since you cannot trust any data coming from the client side, you must first verify the data before using it. We'll go through some examples about how to verify form data in section 4.2. 14 | 15 | We say that HTTP is stateless. How can we identify that certain forms are from the same user? And how do we make sure that one form can only be submitted once? We'll look at some details concerning cookies (a cookie is information that can be saved on the client side and added to the request header when the request is sent to the server) in both sections 4.3 and 4.4. 16 | 17 | Another big use-case of forms is uploading files. In section 4.5, you will learn how to do this as well as controlling the file upload size before it begins uploading, in Go. 18 | 19 | ## Links 20 | 21 | - [Directory](preface.md) 22 | - Previous chapter: [Chapter 3 Summary](03.5.md) 23 | - Next section: [Process form inputs](04.1.md) 24 | -------------------------------------------------------------------------------- /ebook/02.1.md: -------------------------------------------------------------------------------- 1 | # 2.1 你好,Go 2 | 3 | 在开始编写应用之前,我们先从最基本的程序开始。就像你造房子之前不知道什么是地基一样,编写程序也不知道如何开始。因此,在本节中,我们要学习用最基本的语法让Go程序运行起来。 4 | 5 | ## 程序 6 | 7 | 这就像一个传统,在学习大部分语言之前,你先学会如何编写一个可以输出`hello world`的程序。 8 | 9 | 准备好了吗?Let's Go! 10 | 11 | package main 12 | 13 | import "fmt" 14 | 15 | func main() { 16 | fmt.Printf("Hello, world or 你好,世界 or καλημ ́ρα κóσμ or こんにちはせかい\n") 17 | } 18 | 19 | 输出如下: 20 | 21 | Hello, world or 你好,世界 or καλημ ́ρα κóσμ or こんにちはせかい 22 | 23 | ## 详解 24 | 首先我们要了解一个概念,Go程序是通过`package`来组织的 25 | 26 | `package `(在我们的例子中是`package main`)这一行告诉我们当前文件属于哪个包,而包名`main`则告诉我们它是一个可独立运行的包,它在编译后会产生可执行文件。除了`main`包之外,其它的包最后都会生成`*.a`文件(也就是包文件)并放置在`$GOPATH/pkg/$GOOS_$GOARCH`中(以Mac为例就是`$GOPATH/pkg/darwin_amd64`)。 27 | 28 | >每一个可独立运行的Go程序,必定包含一个`package main`,在这个`main`包中必定包含一个入口函数`main`,而这个函数既没有参数,也没有返回值。 29 | 30 | 为了打印`Hello, world...`,我们调用了一个函数`Printf`,这个函数来自于`fmt`包,所以我们在第三行中导入了系统级别的`fmt`包:`import "fmt"`。 31 | 32 | 包的概念和Python中的package类似,它们都有一些特别的好处:模块化(能够把你的程序分成多个模块)和可重用性(每个模块都能被其它应用程序反复使用)。我们在这里只是先了解一下包的概念,后面我们将会编写自己的包。 33 | 34 | 在第五行中,我们通过关键字`func`定义了一个`main`函数,函数体被放在`{}`(大括号)中,就像我们平时写C、C++或Java时一样。 35 | 36 | 大家可以看到`main`函数是没有任何的参数的,我们接下来就学习如何编写带参数的、返回0个或多个值的函数。 37 | 38 | 第六行,我们调用了`fmt`包里面定义的函数`Printf`。大家可以看到,这个函数是通过`.`的方式调用的,这一点和Python十分相似。 39 | 40 | >前面提到过,包名和包所在的文件夹名可以是不同的,此处的``即为通过`package `声明的包名,而非文件夹名。 41 | 42 | 最后大家可以看到我们输出的内容里面包含了很多非ASCII码字符。实际上,Go是天生支持UTF-8的,任何字符都可以直接输出,你甚至可以用UTF-8中的任何字符作为标识符。 43 | 44 | 45 | ## 结论 46 | 47 | Go使用`package`(和Python的模块类似)来组织代码。`main.main()`函数(这个函数主要位于主包)是每一个独立的可运行程序的入口点。Go使用UTF-8字符串和标识符(因为UTF-8的发明者也就是Go的发明者),所以它天生就具有多语言的支持。 48 | 49 | ## links 50 | * [目录]() 51 | * 上一节: [Go语言基础](<02.0.md>) 52 | * 下一节: [Go基础](<02.2.md>) 53 | -------------------------------------------------------------------------------- /en/eBook/14.7.md: -------------------------------------------------------------------------------- 1 | # 14.7 Summary 2 | 3 | This chapter explains how to extend the framework based on beego, which includes support for static files, static files, mainly about how to use beego for rapid web development using bootstrap to build a beautiful site; second summary explaining how beego in integrated sessionManager, user-friendly in use beego quickly when using session; Third Summary describes the forms and validation, based on the Go language allows us to define a struct in the process of developing Web from repetitive work of liberation, and joined the after verification of data security can be as far as possible, the fourth summary describes the user authentication, user authentication, there are three main requirements, http basic and http digest certification, third party certification, custom certification through code demonstrates how to use the existing section tripartite package integrated into beego applications to achieve these certifications; fifth section describes multi-language support, beego integrated go-i18n this multi-language pack, users can easily use the library develop multi-language Web applications; section six subsections describe how to integrate Go's pprof packages, pprof package is used for performance debugging tools, after the transformation by beego integrated pprof package, enabling users to take advantage of pprof test beego based applications developed by these six subsections introduces us to expand out a relatively strong beego framework that is sufficient to meet most of the current Web applications, users can continue to play to their imagination to expand, I am here only a brief introduction I can think of to compare several important extensions. 4 | 5 | ## Links 6 | 7 | - [Directory](preface.md) 8 | - Previous section: [pprof](14.6.md) 9 | - Next chapter: [Appendix A References](ref.md) 10 | 11 | -------------------------------------------------------------------------------- /en/eBook/13.0.md: -------------------------------------------------------------------------------- 1 | # 13 Build a web framework 2 | 3 | Preceding twelve chapter describes how to develop Web applications through Go, introduced a lot of basic knowledge, development tools and techniques, then we pass this knowledge in this chapter to implement a simple Web framework. Go language to achieve through a complete frame design, the main contents of this framework, the first section describes the structure of a Web framework planning, such as using the MVC pattern to develop, program execution process design, etc.; second section describes the framework the first feature: Routing, how to get access to the URL mapped to the corresponding processing logic; third section describes the processing logic, how to design a common controller, object inheritance after the handler how to handle response and request; fourth section describes how to framework some auxiliary functions, such as log processing, configuration information, etc.; fifth section describes how to implement a blog-based Web framework, including Bowen published, modify, delete, display a list of other operations. 4 | 5 | Through such a complete project example, I expect to be able to allow readers to understand how to develop Web applications, how to build your own directory structure, how to achieve routing, how to achieve the MVC pattern and other aspects of developing content. In the framework prevalent today, MVC is no longer a myth. Many programmers often heard discussions which frame is good, which frame is not good, in fact, the framework is only a tool, there is no good or bad, only suitable or unsuitable, for his is the best, so we write their own framework for the church, then different needs can use their own ideas to be realized. 6 | 7 | ## Links 8 | 9 | - [Directory](preface.md) 10 | - Previous chapter: [Chapter 12 summary](12.5.md) 11 | - Next section: [Project program](13.1.md) 12 | --------------------------------------------------------------------------------