From 8a2f38baa2250c07fa30d40f6ec86a427fdc1d3e Mon Sep 17 00:00:00 2001 From: Goryudyuma Date: Thu, 27 Aug 2015 01:05:01 +0900 Subject: [PATCH 1/8] fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ja/03.1.md リクエスト業->リクエスト行 --- ja/03.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ja/03.1.md b/ja/03.1.md index e4eac116..eb9b68ab 100644 --- a/ja/03.1.md +++ b/ja/03.1.md @@ -76,7 +76,7 @@ HTTPプロトコルはステートレスです。同じクライアントの前 まずRequestパケットの構造を見てみることにしましょう。Requestパケットは3つの部分にわけられます。第一部分はRequest line(リクエスト行)。第二部分はRequest header(リクエストヘッダ)、第三部分はbody(ボディ)と呼ばれます。headerとbodyの間には空行があり、リクエストパケットの例は以下のようなものです。 - GET /domains/example/ HTTP/1.1 //リクエスト業:リクエスト方法 リクエストRUI HTTPプロトコル/プロトコルバージョン + GET /domains/example/ HTTP/1.1 //リクエスト行:リクエスト方法 リクエストRUI HTTPプロトコル/プロトコルバージョン Host:www.iana.org //サーバのホスト名 User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4 //ブラウザ情報 Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 //クライアントが受け取れるmime From e39613a2a08f5c5ec7a3ab7ab5456f5ab8ba55a8 Mon Sep 17 00:00:00 2001 From: Goryudyuma Date: Thu, 27 Aug 2015 15:09:56 +0900 Subject: [PATCH 2/8] fix typo --- ja/03.2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ja/03.2.md b/ja/03.2.md index 71f4a502..fa6b11be 100644 --- a/ja/03.2.md +++ b/ja/03.2.md @@ -52,13 +52,13 @@ 上のコードでWebサーバを書くためにはhttpパッケージの2つの関数を呼ぶだけで良いことがわかります。 ->もしあなたが以前PHPプログラマであれば。こう問うかもしれません。我々のnginx、apacheサーバは必要ないのですかと?なぜならこいつは直接tcpポートを関ししますので、nginxがsやることをやってくれます。またsayhelloNameは実は我々が書いたロジック関数ですので、phpの中のコントローラ(controller)関数に近いものです。 +>もしあなたが以前PHPプログラマであれば。こう問うかもしれません。我々のnginx、apacheサーバは必要ないのですかと?なぜならこいつは直接tcpポートを関ししますので、nginxがやることをやってくれます。またsayhelloNameは実は我々が書いたロジック関数ですので、phpの中のコントローラ(controller)関数に近いものです。 >もしあなたがPythonプログラマであったのなら、tornadoを聞いたことがあると思います。このコードはそれとよく似ていませんか?ええ、その通りです。GoはPythonのような動的な言語によく似た特性を持っています。Webアプリケーションを書くにはとても便利です。 >もしあなたがRubyプログラマであったのなら、RORの/script/serverを起動したのと少し似ている事に気づいたかもしれません。 -Goを通じて簡単な数行のコードでwebサーバを立ち上げることができました。さらにこのWebサーバの内部ではマルチスレッドの特性をサポートしています。続く2つの節でGoが以下にWebのマルチスレッドを実現しているのか細かくご紹介します。 +Goを通じて簡単な数行のコードでwebサーバを立ち上げることができました。さらにこのWebサーバの内部ではマルチスレッドの特性をサポートしています。続く2つの節でGoが如何にWebのマルチスレッドを実現しているのか細かくご紹介します。 ## links * [目次]() From 2a5f37490dcdf5b98d7c472e8aa9875db917f33f Mon Sep 17 00:00:00 2001 From: digitalcraftsman Date: Thu, 27 Aug 2015 16:12:30 +0200 Subject: [PATCH 3/8] Fix typos in c2.3 of the English version --- en/02.3.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/en/02.3.md b/en/02.3.md index 7a53f80b..385d972e 100644 --- a/en/02.3.md +++ b/en/02.3.md @@ -327,7 +327,7 @@ Now we can change the value of `x` in the functions. Why do we use pointers? Wha - Allows us to use more functions to operate on one variable. - Low cost by passing memory addresses (8 bytes), copy is not an efficient way, both in terms of time and space, to pass variables. -- `string`, `slice`, `map` are reference types, so they use pointers when passing to functions by default. (Attention: If you need to change the length of `slice`, you have to pass pointers explicitly) +- `string`, `slice` and `map` are reference types, so they use pointers when passing to functions by default. (Attention: If you need to change the length of `slice`, you have to pass pointers explicitly) ### defer @@ -418,15 +418,15 @@ What's the advantage of this feature? The answer is that it allows us to pass fu fmt.Println("Even elements of slice are: ", even) } -It's very useful when we use interfaces. As you can see `testInt` is a variable that has function type, and return values and arguments of `filter` are the same as `testInt`. Therefore, we can have complex logic in our programs, while maintaining flexibility in our code. +It's very useful when we use interfaces. As you can see `testInt` is a variable that has a function as type and the returned values and arguments of `filter` are the same as those of `testInt`. Therefore, we can have complex logic in our programs, while maintaining flexibility in our code. ### Panic and Recover Go doesn't have `try-catch` structure like Java does. Instead of throwing exceptions, Go uses `panic` and `recover` to deal with errors. However, you shouldn't use `panic` very much, although it's powerful. -Panic is a built-in function to break the normal flow of programs and get into panic status. When a function `F` calls `panic`, `F` will not continue executing but its `defer` functions will continue to execute. Then `F` goes back to the break point which caused the panic status. The program will not terminate until all of these functions return with panic to the first level of that `goroutine`. `panic` can be produced by calling `panic` in the program, and some errors also cause `panic` like array access out of bounds errors. +`Panic` is a built-in function to break the normal flow of programs and get into panic status. When a function `F` calls `panic`, `F` will not continue executing but its `defer` functions will continue to execute. Then `F` goes back to the break point which caused the panic status. The program will not terminate until all of these functions return with panic to the first level of that `goroutine`. `panic` can be produced by calling `panic` in the program, and some errors also cause `panic` like array access out of bounds errors. -Recover is a built-in function to recover `goroutine`s from panic status. Calling `recover` in `defer` functions is useful because normal functions will not be executed when the program is in the panic status. It catches `panic` values if the program is in the panic status, and it gets `nil` if the program is not in panic status. +`Recover` is a built-in function to recover `goroutine`s from panic status. Calling `recover` in `defer` functions is useful because normal functions will not be executed when the program is in the panic status. It catches `panic` values if the program is in the panic status, and it gets `nil` if the program is not in panic status. The following example shows how to use `panic`. From b2198156e3be7b04a4f2c32237379f81966aee05 Mon Sep 17 00:00:00 2001 From: Goryudyuma Date: Sat, 29 Aug 2015 01:37:23 +0900 Subject: [PATCH 4/8] fix escape ` --- ja/05.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ja/05.4.md b/ja/05.4.md index 8d7e22e9..b447da24 100644 --- a/ja/05.4.md +++ b/ja/05.4.md @@ -114,7 +114,7 @@ package main } } -上のコードによって、PostgreSQLが`$1`や`$2といった方法によって引数を渡している様子がお分かりいただけるかとおもいます。MySQLの中の`?`ではありません。また、sql.Openではdsn情報のシンタックスがMySQLのドライバでのdsnシンタックスと異なります。そのため、使用される際はこの違いにご注意ください。 +上のコードによって、PostgreSQLが`$1`や`$2`といった方法によって引数を渡している様子がお分かりいただけるかとおもいます。MySQLの中の`?`ではありません。また、sql.Openではdsn情報のシンタックスがMySQLのドライバでのdsnシンタックスと異なります。そのため、使用される際はこの違いにご注意ください。 また、pgはLastInsertId関数をサポートしていません。PostgreSQLの内部ではMySQLのインクリメンタルなIDを返すといった実装がないためです。その他のコードはほとんど同じです。 From b1834c39d40573aa18a9a8d4743667a4cbc12292 Mon Sep 17 00:00:00 2001 From: Goryudyuma Date: Tue, 1 Sep 2015 00:55:02 +0900 Subject: [PATCH 5/8] fix escape ` --- ja/07.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ja/07.1.md b/ja/07.1.md index 44c3d060..29424aee 100644 --- a/ja/07.1.md +++ b/ja/07.1.md @@ -87,7 +87,7 @@ XMLは本来ツリー構造のデータ形式なので、対応するgo言語の } -上の例では、xmlファイルを解析して対応するstructオブジェクトにするには`xml.Unmarshal`によって行われました。この過程はどのように実現されているのでしょうか?我々のstruct定義の後の方を見てみると`xml:"serverName"のような内容があることがわかります。これはstructの特徴の一つです。struct tagと呼ばれています。これはリフレクションを補助するために用いられます。`Unmarshal`の定義を見てみましょう: +上の例では、xmlファイルを解析して対応するstructオブジェクトにするには`xml.Unmarshal`によって行われました。この過程はどのように実現されているのでしょうか?我々のstruct定義の後の方を見てみると`xml:"serverName"`のような内容があることがわかります。これはstructの特徴の一つです。struct tagと呼ばれています。これはリフレクションを補助するために用いられます。`Unmarshal`の定義を見てみましょう: func Unmarshal(data []byte, v interface{}) error From 5ab5fc06e144ea96f2dd9cfb6e7520fdae807569 Mon Sep 17 00:00:00 2001 From: Tomas Roos Date: Tue, 1 Sep 2015 13:51:28 +0200 Subject: [PATCH 6/8] Update 02.2.md It is not possible to use vname1 := "hello" in var() declaration --- en/02.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/02.2.md b/en/02.2.md index c1366cef..c289d2ca 100644 --- a/en/02.2.md +++ b/en/02.2.md @@ -45,7 +45,7 @@ Well, I know this is still not simple enough for you. Let's see how we fix it. */ vname1, vname2, vname3 := v1, v2, v3 -Now it looks much better. Use `:=` to replace `var` and `type`, this is called a brief statement. But wait, it has one limitation: this form can only be used inside of functions. You will get compile errors if you try to use it outside of function bodies. Therefore, we usually use `var` to define global variables and we can use this brief statement in `var()`. +Now it looks much better. Use `:=` to replace `var` and `type`, this is called a brief statement. But wait, it has one limitation: this form can only be used inside of functions. You will get compile errors if you try to use it outside of function bodies. Therefore, we usually use `var` to define global variables. `_` (blank) is a special variable name. Any value that is given to it will be ignored. For example, we give `35` to `b`, and discard `34`.( ***This example just show you how it works. It looks useless here because we often use this symbol when we get function return values.*** ) From 59c213dc542bcd2796af7ac4890e42b95bcc79cf Mon Sep 17 00:00:00 2001 From: Tomas Roos Date: Tue, 1 Sep 2015 14:19:58 +0200 Subject: [PATCH 7/8] Update 05.1.md spelling error on package database/sql --- en/05.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/05.1.md b/en/05.1.md index a590377e..82316e0a 100644 --- a/en/05.1.md +++ b/en/05.1.md @@ -185,7 +185,7 @@ At this point, you should know a bit about developping database drivers in Go. O ## database/sql -databse/sql defines even more high-level methods on top of database/sql/driver for more convenient database operations, and it suggests that you implement a connection pool. +database/sql defines even more high-level methods on top of database/sql/driver for more convenient database operations, and it suggests that you implement a connection pool. type DB struct { driver driver.Driver From 37fe8c8d12fefe1e9407ef7bc8cb4a5e59eeb349 Mon Sep 17 00:00:00 2001 From: Tomas Roos Date: Tue, 1 Sep 2015 14:23:05 +0200 Subject: [PATCH 8/8] Update 05.2.md typo of package name --- en/05.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/05.2.md b/en/05.2.md index 31a62247..3544e93e 100644 --- a/en/05.2.md +++ b/en/05.2.md @@ -13,7 +13,7 @@ There are a couple of drivers that support MySQL in Go. Some of them implement t I'll use the first driver in the following examples (I use this one in my personal projects too), and I also recommend that you use it for the following reasons: - It's a new database driver and supports more features. -- Fully supports `databse/sql` interface standards. +- Fully supports `database/sql` interface standards. - Supports keepalive, long connections with thread-safety. ## Samples