Merge pull request #1096 from shuuji3/fix-github-spelling

Replace the spelling of `github` and `Github` with `GitHub`
This commit is contained in:
astaxie
2019-06-21 08:32:52 +08:00
committed by GitHub
50 changed files with 3675 additions and 3675 deletions

View File

@@ -92,13 +92,13 @@ Um die Anwendung zu kompilieren, müssen wir zurück in das Verzeichnis, in welc
## Installation von Paketen Dritter (Remote Packages) ## Installation von Paketen Dritter (Remote Packages)
Go umfasst ein Werkzeug zum Installieren von Remote Packages, also Paketen die von anderen Programmierern erstellt wurden. Mit dem Befehl `go get` kannst Du diese für die eigene Nutzung installieren. Es unterstützt die meisten Open Source Communities wie Github, Google Code, Bitbucket und Launchpad. Go umfasst ein Werkzeug zum Installieren von Remote Packages, also Paketen die von anderen Programmierern erstellt wurden. Mit dem Befehl `go get` kannst Du diese für die eigene Nutzung installieren. Es unterstützt die meisten Open Source Communities wie GitHub, Google Code, Bitbucket und Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
Du kannst `go get -u …` nutzen, um ein Remote Package zu aktualisieren. Zugleich werden auch alle benötigten Abhängigkeiten mit installiert. Du kannst `go get -u …` nutzen, um ein Remote Package zu aktualisieren. Zugleich werden auch alle benötigten Abhängigkeiten mit installiert.
Dieser Befehl nutzt verschiedene Versionskontrollsysteme für die verschiedenen Open Source Plattformen. So wird beispielsweise `git` für Github und `hg` für Google Code verwendet. Daher musst Du zuerst die entsprechenden Versionskontrollsysteme installieren, ehe Du `go get` nutzen kannst. Dieser Befehl nutzt verschiedene Versionskontrollsysteme für die verschiedenen Open Source Plattformen. So wird beispielsweise `git` für GitHub und `hg` für Google Code verwendet. Daher musst Du zuerst die entsprechenden Versionskontrollsysteme installieren, ehe Du `go get` nutzen kannst.
Nach dem Ausführen der oben gezeigten Befehle, sollte die Orderstruktur etwa so aussehen. Nach dem Ausführen der oben gezeigten Befehle, sollte die Orderstruktur etwa so aussehen.

View File

@@ -43,7 +43,7 @@ Dieser Befehl löscht alle Dateien, die vom Kompiler generiert wurden, einschlie
DIR.test(.exe) // Generiert von go test -c DIR.test(.exe) // Generiert von go test -c
MAINFILE(.exe) // Generiert von go build MAINFILE.go MAINFILE(.exe) // Generiert von go build MAINFILE.go
Überlicherweise nutze ich diese Befehle zum Säubern von Projekten, bevor ich diese auf Github hochlade. Sie sind nützlich für lokale Tests, aber nutzlos zur Versionskontrolle. Überlicherweise nutze ich diese Befehle zum Säubern von Projekten, bevor ich diese auf GitHub hochlade. Sie sind nützlich für lokale Tests, aber nutzlos zur Versionskontrolle.
## go fmt und gofmt ## go fmt und gofmt
@@ -56,10 +56,10 @@ Wir nutzen üblicherweise `gofmt -w` statt `go fmt`. Somit wird Deine Quellcoded
## go get ## go get
Dieser Befehl ermöglicht es, Remote Packages herunterzuladen. Bisher untersützt es Bitbucket, Github, Google Code und Launchpad. Es geschehen zwei Dinge, nachdem wir den Befehl ausgeführt haben. Als erstes lädt Go den Quellcode herunter und führt danach `go install` aus. Bevor Du `go get` nutzt, solltest Du vorher die benötigten Versionskontrollsysteme herunterladen. Dieser Befehl ermöglicht es, Remote Packages herunterzuladen. Bisher untersützt es Bitbucket, GitHub, Google Code und Launchpad. Es geschehen zwei Dinge, nachdem wir den Befehl ausgeführt haben. Als erstes lädt Go den Quellcode herunter und führt danach `go install` aus. Bevor Du `go get` nutzt, solltest Du vorher die benötigten Versionskontrollsysteme herunterladen.
BitBucket (Mercurial und Git) BitBucket (Mercurial und Git)
Github (Git) GitHub (Git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -4,7 +4,7 @@ When our web application is finally production ready, what are the steps necessa
## Daemons ## Daemons
Currently, Go programs cannot cannot be run as daemon processes (for additional information, see the open issue on github [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used. Currently, Go programs cannot cannot be run as daemon processes (for additional information, see the open issue on GitHub [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used.
We can, however, see many attempts at implementing daemons online, such as in the two following ways; We can, however, see many attempts at implementing daemons online, such as in the two following ways;

View File

@@ -56,7 +56,7 @@ OAuth and OAuth 2 are currently two of the most popular authentication methods.
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
The code below demonstrates how to use this library to implement OAuth authentication in Beego using our Github credentials: The code below demonstrates how to use this library to implement OAuth authentication in Beego using our GitHub credentials:
1. Let's add some routes 1. Let's add some routes
@@ -147,7 +147,7 @@ After clicking "Authorize app", the following screen appears:
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
Figure 14.6 authorized Github information gets displayed after the login page Figure 14.6 authorized GitHub information gets displayed after the login page
## Custom authentication ## Custom authentication

View File

@@ -95,13 +95,13 @@ To compile this application, you need to switch to the application directory, wh
## Install remote packages ## Install remote packages
Go has a tool for installing remote packages, which is a command called `go get`. It supports most open source communities, including Github, Google Code, BitBucket, and Launchpad. Go has a tool for installing remote packages, which is a command called `go get`. It supports most open source communities, including GitHub, Google Code, BitBucket, and Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
You can use `go get -u …` to update your remote packages and it will automatically install all the dependent packages as well. You can use `go get -u …` to update your remote packages and it will automatically install all the dependent packages as well.
This tool will use different version control tools for different open source platforms. For example, `git` for Github and `hg` for Google Code. Therefore, you have to install these version control tools before you use `go get`. This tool will use different version control tools for different open source platforms. For example, `git` for GitHub and `hg` for Google Code. Therefore, you have to install these version control tools before you use `go get`.
After executing the above commands, the directory structure should look like following. After executing the above commands, the directory structure should look like following.

View File

@@ -55,10 +55,10 @@ We usually use `gofmt -w` instead of `go fmt`. The latter will not rewrite your
## go get ## go get
This command is for getting remote packages. So far, it supports BitBucket, Github, Google Code and Launchpad. There are actually two things that happen after we execute this command. The first thing is that Go downloads the source code, then executes `go install`. Before you use this command, make sure you have installed all of the related tools. This command is for getting remote packages. So far, it supports BitBucket, GitHub, Google Code and Launchpad. There are actually two things that happen after we execute this command. The first thing is that Go downloads the source code, then executes `go install`. Before you use this command, make sure you have installed all of the related tools.
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -23,7 +23,7 @@ To mitigate all the problems that Google faced with current tools, they wrote a
Go was designed with concurrency in mind, please note that parallelism != concurrency, there is an [amazing post](https://blog.golang.org/concurrency-is-not-parallelism) by Rob Pike on the [golang blog](https://blog.golang.org/), you will find it there, it is worth a read. Go was designed with concurrency in mind, please note that parallelism != concurrency, there is an [amazing post](https://blog.golang.org/concurrency-is-not-parallelism) by Rob Pike on the [golang blog](https://blog.golang.org/), you will find it there, it is worth a read.
Another very important change that is the concept of `GOPATH`. Gone are the days when you had to create a folder called `code` and then create workspaces for eclipse and what not. Now you have to keep one folder tree for go code which will be updated by the package manager automatically. It is also recommended to create folders with either a custom domain or the github domain, for example I created a task manager using golang so I created a set of folders Another very important change that is the concept of `GOPATH`. Gone are the days when you had to create a folder called `code` and then create workspaces for eclipse and what not. Now you have to keep one folder tree for go code which will be updated by the package manager automatically. It is also recommended to create folders with either a custom domain or the GitHub domain, for example I created a task manager using golang so I created a set of folders
`~/go/src/github.com/thewhitetulip/Tasks` `~/go/src/github.com/thewhitetulip/Tasks`
**Note:** In *nix systems `~` stands for home directory, which is the windows equivalent of `C:\\Users\\username`. **Note:** In *nix systems `~` stands for home directory, which is the windows equivalent of `C:\\Users\\username`.

View File

@@ -4,7 +4,7 @@ When our web application is finally production ready, what are the steps necessa
## Daemons ## Daemons
Currently, Go programs cannot be run as daemon processes (for additional information, see the open issue on github [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used. Currently, Go programs cannot be run as daemon processes (for additional information, see the open issue on GitHub [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used.
We can, however, see many attempts at implementing daemons online, such as in the two following ways; We can, however, see many attempts at implementing daemons online, such as in the two following ways;

View File

@@ -56,7 +56,7 @@ OAuth and OAuth 2 are currently two of the most popular authentication methods.
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
The code below demonstrates how to use this library to implement OAuth authentication in Beego using our Github credentials: The code below demonstrates how to use this library to implement OAuth authentication in Beego using our GitHub credentials:
1. Let's add some routes 1. Let's add some routes
@@ -147,7 +147,7 @@ After clicking "Authorize app", the following screen appears:
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
Figure 14.6 authorized Github information gets displayed after the login page Figure 14.6 authorized GitHub information gets displayed after the login page
## Custom authentication ## Custom authentication

View File

@@ -90,13 +90,13 @@ Para compilar esta aplicación necesitas cambiar al directorio de la aplicación
``` ```
## Instala paquete remotos ## Instala paquete remotos
Go tiene una herramienta para instalar paquetes remotos, es el comando llamado `go get`. Soporta la mayoría de comunidades de código libre, incluyendo Github, Google Code, BitBucket y Launchpad. Go tiene una herramienta para instalar paquetes remotos, es el comando llamado `go get`. Soporta la mayoría de comunidades de código libre, incluyendo GitHub, Google Code, BitBucket y Launchpad.
``` ```
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
``` ```
Puedes usar `go get -u …` para actualizar tus paquetes remotos e incluso instalará todas sus dependencias. Puedes usar `go get -u …` para actualizar tus paquetes remotos e incluso instalará todas sus dependencias.
Esta herramienta usará diferente herramientas de control de versiones para las diferentes plataformas de código libre. Por ejemplo, `git` para Github y `hg` para Google Code. Debido a esto, debes instalar estas herramientas de control de versiones antes de usar `go get`. Esta herramienta usará diferente herramientas de control de versiones para las diferentes plataformas de código libre. Por ejemplo, `git` para GitHub y `hg` para Google Code. Debido a esto, debes instalar estas herramientas de control de versiones antes de usar `go get`.
Después de ejecutar los comandos anteriormente descritos, la estructura de directorios debería verse de la siguiente forma: Después de ejecutar los comandos anteriormente descritos, la estructura de directorios debería verse de la siguiente forma:
``` ```

View File

@@ -53,10 +53,10 @@ Usualmente usamos `gofmt -w` en vez de `go fmt`. El último, no rescribirá tus
## go get ## go get
Este comando es para obtener paquetes remotos. Hasta el momento soporta BitBucket, Github, Google Code y Launchpad. Actualmente existen dos cosas que suceden después de ejecutar este comando. La primera es que Go descarga el código fuente, luego ejecuta `go install`. Antes de que utilices este comando, asegúrate que tienes instaladas todas las herramientas relacionadas. Este comando es para obtener paquetes remotos. Hasta el momento soporta BitBucket, GitHub, Google Code y Launchpad. Actualmente existen dos cosas que suceden después de ejecutar este comando. La primera es que Go descarga el código fuente, luego ejecuta `go install`. Antes de que utilices este comando, asegúrate que tienes instaladas todas las herramientas relacionadas.
``` ```
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)
``` ```

View File

@@ -23,7 +23,7 @@ Entonces para mitigar todos los problemas que Google enfrentó con las herramien
Go fue diseñado con la concurrencia en mente, por favor note que paralelismo != concurrencia. Hay un post maravilloso escrito por Bob Pike en el blog de Go, blog.golang.org, que usted encontraréa ahí y vale la pena leerlo. Go fue diseñado con la concurrencia en mente, por favor note que paralelismo != concurrencia. Hay un post maravilloso escrito por Bob Pike en el blog de Go, blog.golang.org, que usted encontraréa ahí y vale la pena leerlo.
Otro cambio muy importante que Go trajo a la programación y que yo personalmente amo, es le concepto de `GOPATH`, los tiempos donde tenías que crear una carpeta llamada code y entonces crear espacios de trabajo para eclipse y otros. Ahora usted puede tener un árbol de carpetas para el código en Go y se mantendrá actualizado automáticamente por el administrador de paquetes. También bajo el código que estamos recomendando crear carpetas con cada dominio específico o el dominio de github, por ejemplo yo creé un manejador de tareas usando Go, entonces creé un conjunto de carpetas Otro cambio muy importante que Go trajo a la programación y que yo personalmente amo, es le concepto de `GOPATH`, los tiempos donde tenías que crear una carpeta llamada code y entonces crear espacios de trabajo para eclipse y otros. Ahora usted puede tener un árbol de carpetas para el código en Go y se mantendrá actualizado automáticamente por el administrador de paquetes. También bajo el código que estamos recomendando crear carpetas con cada dominio específico o el dominio de GitHub, por ejemplo yo creé un manejador de tareas usando Go, entonces creé un conjunto de carpetas
`~/go/src/github.com/thewhitetulip/Tasks` Nota: En sistemas * nix `~` se refiere al directorio del usuario, que en windows es equivalente a `C:\\Users\\username` `~/go/src/github.com/thewhitetulip/Tasks` Nota: En sistemas * nix `~` se refiere al directorio del usuario, que en windows es equivalente a `C:\\Users\\username`
Ahora el `~/go/` es el universo de código Go en su máquina, este es solo una significante mejora en comparación con otros lenguajes, entonces podemos almacenar código eficientemente sin molestias, esto puede parecer raro al comienzo pero tiene un montón de sentido a comparación de los nombres de paquete en otros lenguajes que usan sistemas como el del dominio inverso. Ahora el `~/go/` es el universo de código Go en su máquina, este es solo una significante mejora en comparación con otros lenguajes, entonces podemos almacenar código eficientemente sin molestias, esto puede parecer raro al comienzo pero tiene un montón de sentido a comparación de los nombres de paquete en otros lenguajes que usan sistemas como el del dominio inverso.

View File

@@ -95,13 +95,13 @@ func main() {
## نصب بسته‌های ریموت ## نصب بسته‌های ریموت
Go has a tool for installing remote packages, which is a command called `go get`. It supports most open source communities, including Github, Google Code, BitBucket, and Launchpad. Go has a tool for installing remote packages, which is a command called `go get`. It supports most open source communities, including GitHub, Google Code, BitBucket, and Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
You can use `go get -u …` to update your remote packages and it will automatically install all the dependent packages as well. You can use `go get -u …` to update your remote packages and it will automatically install all the dependent packages as well.
This tool will use different version control tools for different open source platforms. For example, `git` for Github and `hg` for Google Code. Therefore, you have to install these version control tools before you use `go get`. This tool will use different version control tools for different open source platforms. For example, `git` for GitHub and `hg` for Google Code. Therefore, you have to install these version control tools before you use `go get`.
After executing the above commands, the directory structure should look like following. After executing the above commands, the directory structure should look like following.

View File

@@ -55,10 +55,10 @@ We usually use `gofmt -w` instead of `go fmt`. The latter will not rewrite your
## go get ## go get
This command is for getting remote packages. So far, it supports BitBucket, Github, Google Code and Launchpad. There are actually two things that happen after we execute this command. The first thing is that Go downloads the source code, then executes `go install`. Before you use this command, make sure you have installed all of the related tools. This command is for getting remote packages. So far, it supports BitBucket, GitHub, Google Code and Launchpad. There are actually two things that happen after we execute this command. The first thing is that Go downloads the source code, then executes `go install`. Before you use this command, make sure you have installed all of the related tools.
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -115,14 +115,14 @@ Vous devriez voir le contenu suivant dans votre temrinal:
## Installer des paquets distants ## Installer des paquets distants
Go a un outil pour installer des paquets distants, qui est l'outil `go get`.Il supporte la majorité des communautés libres, comme Go a un outil pour installer des paquets distants, qui est l'outil `go get`.Il supporte la majorité des communautés libres, comme
Github, Google Code, BitBucket, et Launchpad. GitHub, Google Code, BitBucket, et Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
>Vous pouvez utiliser `go get -u` pour mettre à jour vos paquets distants, cela mettra aussi à jour les dépendances. >Vous pouvez utiliser `go get -u` pour mettre à jour vos paquets distants, cela mettra aussi à jour les dépendances.
Vous obtiendrez le code source des paquets désirés grâce à cette commande, depuis différentes plate-formes, utilisant chacune leur système de gestion de version. Vous obtiendrez le code source des paquets désirés grâce à cette commande, depuis différentes plate-formes, utilisant chacune leur système de gestion de version.
Par exemple, `git` pour Github et `hg` pour Google Code. Ainsi vous devrez au préalable installer le client du système de gestion de version approprié Par exemple, `git` pour GitHub et `hg` pour Google Code. Ainsi vous devrez au préalable installer le client du système de gestion de version approprié
avant d'utiliser`go get`. avant d'utiliser`go get`.
Après avoir utilisé les commandes précédentes, votre structure de dossier devrait ressembler à celle-ci: Après avoir utilisé les commandes précédentes, votre structure de dossier devrait ressembler à celle-ci:

View File

@@ -69,13 +69,13 @@ Ce dernier ne modifie pas vos fichiers source après formattage. `gofmt -w src`
## go get ## go get
Cette commande récupère des paquets distants. Sont supportés BitBucket, Github, Google Code et Launchpad. Cette commande récupère des paquets distants. Sont supportés BitBucket, GitHub, Google Code et Launchpad.
Il se passe en fait deux choses à l'exécution de cette commande. Il se passe en fait deux choses à l'exécution de cette commande.
En premier lieu, Go télécharge le code source, puis il exécute `go install`. En premier lieu, Go télécharge le code source, puis il exécute `go install`.
Avant d'utiliser cette commande, assurez-vous d'installer les outils nécessaires. Avant d'utiliser cette commande, assurez-vous d'installer les outils nécessaires.
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -119,13 +119,13 @@ mathapp
ここではどのように実行可能アプリケーションをコンパイル/インストールし、ディレクトリ構造を設計するかについてご紹介しました。 ここではどのように実行可能アプリケーションをコンパイル/インストールし、ディレクトリ構造を設計するかについてご紹介しました。
## リモートパッケージの取得 ## リモートパッケージの取得
go言語はリモートパッケージを取得するツール`go get`を持っています。現在go getは多数のオープンソースリポジトリをサポートしていますgithub、googlecode、bitbucket、Launchpad go言語はリモートパッケージを取得するツール`go get`を持っています。現在go getは多数のオープンソースリポジトリをサポートしていますGitHub、googlecode、bitbucket、Launchpad
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
>go get -u オプションはパッケージの自動更新を行います。また、go get時に自動的に当該のパッケージの依存する他のサードパーティパッケージを取得します。 >go get -u オプションはパッケージの自動更新を行います。また、go get時に自動的に当該のパッケージの依存する他のサードパーティパッケージを取得します。
このコマンドでふさわしいコードを取得し、対応するオープンソースプラットホームに対し異なるソースコントロールツールを利用します。例えばgithubではgit、googlecodeではhg。そのためこれらのコードを取得したい場合は、先に対応するソースコードコントロールツールをインストールしておく必要があります。 このコマンドでふさわしいコードを取得し、対応するオープンソースプラットホームに対し異なるソースコントロールツールを利用します。例えばGitHubではgit、googlecodeではhg。そのためこれらのコードを取得したい場合は、先に対応するソースコードコントロールツールをインストールしておく必要があります。
上述の方法で取得したコードはローカルの以下の場所に配置されます。 上述の方法で取得したコードはローカルの以下の場所に配置されます。

View File

@@ -350,7 +350,7 @@ Eclipseも非常によく使われる開発ツールです。以下ではEclipse
3. gocodeをダウンロードして、goのコード補完を表示させます。 3. gocodeをダウンロードして、goのコード補完を表示させます。
gocodeのgithubアドレス gocodeのGitHubアドレス
https://github.com/nsf/gocode https://github.com/nsf/gocode

View File

@@ -13,7 +13,7 @@ GoはPostgreSQLをサポートしたドライバも非常に多く実装され
- https://github.com/jbarham/gopgsqldriver database/sqlドライバをサポートしています。純粋にGoで書かれています。 - https://github.com/jbarham/gopgsqldriver database/sqlドライバをサポートしています。純粋にGoで書かれています。
- https://github.com/lxn/go-pgsql database/sqlドライバをサポートしています。純粋にGoで書かれています。 - https://github.com/lxn/go-pgsql database/sqlドライバをサポートしています。純粋にGoで書かれています。
下の例では一つ目のドライバを採用してご説明します。これは使用している人が最も多く、githubでも比較的活発であるからです。 下の例では一つ目のドライバを採用してご説明します。これは使用している人が最も多く、GitHubでも比較的活発であるからです。
## 実例コード ## 実例コード
データベースのテーブル作成文: データベースのテーブル作成文:

View File

@@ -1,5 +1,5 @@
# 13.6 まとめ # 13.6 まとめ
この章ではどのように基礎的なGo言語のフレームワークを実装するかについてご紹介しました。フレームワークにはルーティング設計が含まれます。Goのビルトインのhttpパッケージにあるルーティングにはいくつか足りない部分があるため、我々は動的なルーティング規則を設計し、その後MVCモデルにおけるController設計をご紹介しました。controllerはRESTを実装しており、主な考え方はtornadeフレームワークからきています。次にも出るのlayoutおよびテンプレートの自動化技術を実装しました。主に採用したのはGoのビルトインのモデルエンジンです。最後に補足的なログ、設定といった情報の設計をご紹介しました。これらの設計を通して基礎的なフレームワークbeegoを実装しました。現在このフレームワークはすでにgithub上でオープンソースになっています。最後に我々はbeegoを通じてブログシステムの実装を行いました。この実例コードを通してどのように快速にホームページを開発するのかが見渡せたのではないかと思います。 この章ではどのように基礎的なGo言語のフレームワークを実装するかについてご紹介しました。フレームワークにはルーティング設計が含まれます。Goのビルトインのhttpパッケージにあるルーティングにはいくつか足りない部分があるため、我々は動的なルーティング規則を設計し、その後MVCモデルにおけるController設計をご紹介しました。controllerはRESTを実装しており、主な考え方はtornadeフレームワークからきています。次にも出るのlayoutおよびテンプレートの自動化技術を実装しました。主に採用したのはGoのビルトインのモデルエンジンです。最後に補足的なログ、設定といった情報の設計をご紹介しました。これらの設計を通して基礎的なフレームワークbeegoを実装しました。現在このフレームワークはすでにGitHub上でオープンソースになっています。最後に我々はbeegoを通じてブログシステムの実装を行いました。この実例コードを通してどのように快速にホームページを開発するのかが見渡せたのではないかと思います。
## links ## links
* [目次](<preface.md>) * [目次](<preface.md>)

View File

@@ -2,7 +2,7 @@
Webアプリケーションを開発する過程で、ユーザ認証は開発者がよくぶつかる問題です。ユーザのログイン、サインアップ、ログアウト等といった操作で、一般的な認証はつの方面の認証に分けることができます Webアプリケーションを開発する過程で、ユーザ認証は開発者がよくぶつかる問題です。ユーザのログイン、サインアップ、ログアウト等といった操作で、一般的な認証はつの方面の認証に分けることができます
- HTTP BasicとHTTP Digest認証 - HTTP BasicとHTTP Digest認証
- サードパーティ認証QQ、weibo、doubian、OPENID、google、github、facebookおよびtwitterなどです - サードパーティ認証QQ、weibo、doubian、OPENID、google、GitHub、facebookおよびtwitterなどです
- カスタム定義のユーザログイン、サインアップ、ログアウトは一般的にsession、cookie認証にもとづいています。 - カスタム定義のユーザログイン、サインアップ、ログアウトは一般的にsession、cookie認証にもとづいています。
beegoは現在このつの方式のどの形式にも対応していません。しかしサードパーティのオープンソースライブラリによって上のつの方法のユーザ認証を実装することができます。しかし後々beegoは前者つの認証を一つ一つ実装するかもしれません。 beegoは現在このつの方式のどの形式にも対応していません。しかしサードパーティのオープンソースライブラリによって上のつの方法のユーザ認証を実装することができます。しかし後々beegoは前者つの認証を一つ一つ実装するかもしれません。
@@ -53,7 +53,7 @@ oauthとoauth2は現在比較的流行している二種類の認証方式です
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
下のコードはどのようにしてこのライブラリをbeegoの中に導入しoauth認証を実装するか示しています。ここではgithubを例にしています 下のコードはどのようにしてこのライブラリをbeegoの中に導入しoauth認証を実装するか示しています。ここではGitHubを例にしています
1. ルーティングを2本追加 1. ルーティングを2本追加
@@ -137,13 +137,13 @@ oauthとoauth2は現在比較的流行している二種類の認証方式です
![](images/14.4.github2.png?raw=true) ![](images/14.4.github2.png?raw=true)
図14.5 ログインボタンをクリックしてgithubの権限取得ページを表示 図14.5 ログインボタンをクリックしてGitHubの権限取得ページを表示
Authorize appをクリックすると以下のようなインターフェースが現れます Authorize appをクリックすると以下のようなインターフェースが現れます
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
図14.6 権限取得にログインした後表示される取得済みのgithub情報のページ 図14.6 権限取得にログインした後表示される取得済みのGitHub情報のページ
## カスタム定義認証 ## カスタム定義認証
カスタム定義の認証は一般的にはsessionと組み合わせて検証されます。以下のコードはあるbeegoのオープンソースブログに基づいています カスタム定義の認証は一般的にはsessionと組み合わせて検証されます。以下のコードはあるbeegoのオープンソースブログに基づいています

View File

@@ -91,7 +91,7 @@ Para compilar nossa aplicação, deveremos alterar o código fonte de diretório
## Instalando pacotes remotamente ## Instalando pacotes remotamente
Go possui uma ferramenta para utilizar pacotes remotos, chamada `go get`. Ela é suportada por grandes comunidades de código aberto, incluindo: Github, Google Code, Bitbucket e Launchpad. Go possui uma ferramenta para utilizar pacotes remotos, chamada `go get`. Ela é suportada por grandes comunidades de código aberto, incluindo: GitHub, Google Code, Bitbucket e Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb

View File

@@ -56,10 +56,10 @@ Normalmente, usamos o comando `gofmt -w` ao invés de simplesmente `go fmt`. A d
## go get ## go get
Esse comando serve para obtenção de pacotes remotamente. Até o momento, o comando suporta BitBucket, Github, Google Code e Launchpad. De fato, duas coisas ocorrem quando esse comando é executado. Primeiramente é feito o download do código fonte e então é executado o comando `go install`. Antes de utilizar esse comando, tenha certeza de possuir instalados as seguintes ferramentas. Esse comando serve para obtenção de pacotes remotamente. Até o momento, o comando suporta BitBucket, GitHub, Google Code e Launchpad. De fato, duas coisas ocorrem quando esse comando é executado. Primeiramente é feito o download do código fonte e então é executado o comando `go install`. Antes de utilizar esse comando, tenha certeza de possuir instalados as seguintes ferramentas.
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -4,7 +4,7 @@ When our web application is finally production ready, what are the steps necessa
## Daemons ## Daemons
Currently, Go programs cannot cannot be run as daemon processes (for additional information, see the open issue on github [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used. Currently, Go programs cannot cannot be run as daemon processes (for additional information, see the open issue on GitHub [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used.
We can, however, see many attempts at implementing daemons online, such as in the two following ways; We can, however, see many attempts at implementing daemons online, such as in the two following ways;

View File

@@ -56,7 +56,7 @@ OAuth and OAuth 2 are currently two of the most popular authentication methods.
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
The code below demonstrates how to use this library to implement OAuth authentication in Beego using our Github credentials: The code below demonstrates how to use this library to implement OAuth authentication in Beego using our GitHub credentials:
1. Let's add some routes 1. Let's add some routes
@@ -147,7 +147,7 @@ After clicking "Authorize app", the following screen appears:
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
Figure 14.6 authorized Github information gets displayed after the login page Figure 14.6 authorized GitHub information gets displayed after the login page
## Custom authentication ## Custom authentication

View File

@@ -90,13 +90,13 @@ func main() {
## Установка удаленных пакетов ## Установка удаленных пакетов
В Go есть инструмент для установки удаленных пакетов - команда `go get`. Он поддерживает работу с большинством сообществ Open Source, включая Github, Google Code, BitBucket и Launchpad. В Go есть инструмент для установки удаленных пакетов - команда `go get`. Он поддерживает работу с большинством сообществ Open Source, включая GitHub, Google Code, BitBucket и Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
Чтобы обновить Ваши удаленные пакеты, выполните `go get -u …`, при этом установятся все дополнительные зависимости . Чтобы обновить Ваши удаленные пакеты, выполните `go get -u …`, при этом установятся все дополнительные зависимости .
Для разных Open Source платформ потребуются различные системы контроля версий, например `git` для Github и `hg` для Google Code. Поэтому Вам нужно установить соответствующие системы контроля версий перед использованием `go get`. Для разных Open Source платформ потребуются различные системы контроля версий, например `git` для GitHub и `hg` для Google Code. Поэтому Вам нужно установить соответствующие системы контроля версий перед использованием `go get`.
После выполнения команд выше структура каталогов будет выглядеть следующим образом: После выполнения команд выше структура каталогов будет выглядеть следующим образом:

View File

@@ -55,10 +55,10 @@
## go get ## go get
Эта команда служит для установки удаленных пакетов. На данный момент она поддерживает BitBucket, Github, Google Code и Launchpad. При запуске этой команды происходят вещи: первая - Go скачивает исходники пакетов, вторая - исполняется `go install`. Перед использованием этой команды убедитесь, что у Вас установлены соответствующие инструменты: Эта команда служит для установки удаленных пакетов. На данный момент она поддерживает BitBucket, GitHub, Google Code и Launchpad. При запуске этой команды происходят вещи: первая - Go скачивает исходники пакетов, вторая - исполняется `go install`. Перед использованием этой команды убедитесь, что у Вас установлены соответствующие инструменты:
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -327,7 +327,7 @@ Eclipse также является отличным инструментом р
2. Скачайте [goclipse](https://code.google.com/p/goclipse/) [http://code.google.com/p/goclipse/wiki/InstallationInstructions](http://code.google.com/p/goclipse/wiki/InstallationInstructions). 2. Скачайте [goclipse](https://code.google.com/p/goclipse/) [http://code.google.com/p/goclipse/wiki/InstallationInstructions](http://code.google.com/p/goclipse/wiki/InstallationInstructions).
3. Скачайте gocode: 3. Скачайте gocode:
gocode на Github: gocode на GitHub:
https://github.com/nsf/gocode https://github.com/nsf/gocode

View File

@@ -96,13 +96,13 @@ func main() {
## การติดตั้ง package เพิ่มเติม ## การติดตั้ง package เพิ่มเติม
Go มาพร้อมกับเครื่องมือที่ใช้ในการติดตั้ง package เสริม ซึ่งได้แก่คำสั่งที่เรียกว่า `go get` โดยรองรับ opensource comunity เกือบทุกที่ รวมถึง Github, Google Code, BitBucket และ Launchpad Go มาพร้อมกับเครื่องมือที่ใช้ในการติดตั้ง package เสริม ซึ่งได้แก่คำสั่งที่เรียกว่า `go get` โดยรองรับ opensource comunity เกือบทุกที่ รวมถึง GitHub, Google Code, BitBucket และ Launchpad
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
โดยสามารถใช้ `go get -u …` ในการอัพเดท package และยังสามารถติดตั้ง package ที่เป็น dependency ให้โดยอัตโนมัติด้วย โดยสามารถใช้ `go get -u …` ในการอัพเดท package และยังสามารถติดตั้ง package ที่เป็น dependency ให้โดยอัตโนมัติด้วย
ซึ่งเครื่องมือนี้จะใช้ version control ที่แตกต่างกันสำหรับแต่ละ opensource platform ยกตัวอย่างเช่น จะใช้่่ `git` สำหรับ Github และใช้ `hg` สำหรับ Google Code ดังนั้นเราจำเป็นที่จะต้องติดตั้งเครื่องมือ version control เหล่านี้ก่อนที่เราจะใช้ `go get` ได้ ซึ่งเครื่องมือนี้จะใช้ version control ที่แตกต่างกันสำหรับแต่ละ opensource platform ยกตัวอย่างเช่น จะใช้่่ `git` สำหรับ GitHub และใช้ `hg` สำหรับ Google Code ดังนั้นเราจำเป็นที่จะต้องติดตั้งเครื่องมือ version control เหล่านี้ก่อนที่เราจะใช้ `go get` ได้
หลังจากที่รันคำสั่งที่กล่าวมาแล้ว โครงสร้างไดเร็คทอรีควรมีหน้าตาดังนี้ หลังจากที่รันคำสั่งที่กล่าวมาแล้ว โครงสร้างไดเร็คทอรีควรมีหน้าตาดังนี้

View File

@@ -43,7 +43,7 @@
DIR.test(.exe) // สร้างจากคำสั่ง go test -c DIR.test(.exe) // สร้างจากคำสั่ง go test -c
MAINFILE(.exe) // สร้างจากคำสั่ง go build MAINFILE.go MAINFILE(.exe) // สร้างจากคำสั่ง go build MAINFILE.go
โดยปรกติผมจะใช้คำสั่งนี้เพื่อลบไฟล์ที่ไม่ต้องการก่อนที่จะอัพโหลดโปรเจ็คไปที่ Github ซึ่งไฟล์เหล่านี้มีประโยชน์ในการทำงานบนเครื่อง แต่ไม่ได้มีประโยชน์กับ version control โดยปรกติผมจะใช้คำสั่งนี้เพื่อลบไฟล์ที่ไม่ต้องการก่อนที่จะอัพโหลดโปรเจ็คไปที่ GitHub ซึ่งไฟล์เหล่านี้มีประโยชน์ในการทำงานบนเครื่อง แต่ไม่ได้มีประโยชน์กับ version control
## go fmt และ gofmt ## go fmt และ gofmt
@@ -56,10 +56,10 @@
## go get ## go get
คำสั่งนี้จะเป็นการดึง package มาใช้งานจากเครื่องอื่น โดยตั้งแต่ต้นนั้นจะ support การดึงมาจาก BitBucket, Github, Google Code และ Launchpad โดยจะเกิดการทำงานสองอย่างขึ้นจากการสั่งคำสั่งนี้ อย่างแรกคือ Go จะดาวน์โหลด source code มา เสร็จแล้วจะสั่ง `go install` ให้เองเลย แต่ก่อนที่เราจะใช้คำสั่งนี้ กรุณาตรวจสอบให้มั่นใจว่ามีการติดตั้งเครื่องมือที่เกี่ยวข้องไว้ก่อนแล้ว ดังนี้ คำสั่งนี้จะเป็นการดึง package มาใช้งานจากเครื่องอื่น โดยตั้งแต่ต้นนั้นจะ support การดึงมาจาก BitBucket, GitHub, Google Code และ Launchpad โดยจะเกิดการทำงานสองอย่างขึ้นจากการสั่งคำสั่งนี้ อย่างแรกคือ Go จะดาวน์โหลด source code มา เสร็จแล้วจะสั่ง `go install` ให้เองเลย แต่ก่อนที่เราจะใช้คำสั่งนี้ กรุณาตรวจสอบให้มั่นใจว่ามีการติดตั้งเครื่องมือที่เกี่ยวข้องไว้ก่อนแล้ว ดังนี้
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -23,7 +23,7 @@ To mitigate all the problems that Google faced with current tools, they wrote a
Go was designed with concurrency in mind, please note that parallelism != concurrency, there is an [amazing post](https://blog.golang.org/concurrency-is-not-parallelism) by Rob Pike on the [golang blog](https://blog.golang.org/), you will find it there, it is worth a read. Go was designed with concurrency in mind, please note that parallelism != concurrency, there is an [amazing post](https://blog.golang.org/concurrency-is-not-parallelism) by Rob Pike on the [golang blog](https://blog.golang.org/), you will find it there, it is worth a read.
Another very important change that is the concept of `GOPATH`. Gone are the days when you had to create a folder called `code` and then create workspaces for eclipse and what not. Now you have to keep one folder tree for go code which will be updated by the package manager automatically. It is also recommended to create folders with either a custom domain or the github domain, for example I created a task manager using golang so I created a set of folders Another very important change that is the concept of `GOPATH`. Gone are the days when you had to create a folder called `code` and then create workspaces for eclipse and what not. Now you have to keep one folder tree for go code which will be updated by the package manager automatically. It is also recommended to create folders with either a custom domain or the GitHub domain, for example I created a task manager using golang so I created a set of folders
`~/go/src/github.com/thewhitetulip/Tasks` `~/go/src/github.com/thewhitetulip/Tasks`
**Note:** In *nix systems `~` stands for home directory, which is the windows equivalent of `C:\\Users\\username`. **Note:** In *nix systems `~` stands for home directory, which is the windows equivalent of `C:\\Users\\username`.

View File

@@ -4,7 +4,7 @@ When our web application is finally production ready, what are the steps necessa
## Daemons ## Daemons
Currently, Go programs cannot be run as daemon processes (for additional information, see the open issue on github [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used. Currently, Go programs cannot be run as daemon processes (for additional information, see the open issue on GitHub [here](https://github.com/golang/go/issues/227)). It's difficult to fork existing threads in Go because there is no way of ensuring a consistent state in all threads that have been used.
We can, however, see many attempts at implementing daemons online, such as in the two following ways; We can, however, see many attempts at implementing daemons online, such as in the two following ways;

View File

@@ -56,7 +56,7 @@ OAuth and OAuth 2 are currently two of the most popular authentication methods.
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
The code below demonstrates how to use this library to implement OAuth authentication in Beego using our Github credentials: The code below demonstrates how to use this library to implement OAuth authentication in Beego using our GitHub credentials:
1. Let's add some routes 1. Let's add some routes
@@ -147,7 +147,7 @@ After clicking "Authorize app", the following screen appears:
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
Figure 14.6 authorized Github information gets displayed after the login page Figure 14.6 authorized GitHub information gets displayed after the login page
## Custom authentication ## Custom authentication

View File

@@ -90,7 +90,7 @@ Uygulamyı derlemek için, `$GOPATH/src/mathapp` dizinine geçip, `go install` k
## Üçüncü-parti paketleri kurmak ## Üçüncü-parti paketleri kurmak
Üçüncü-parti paketleri kurmak için `go get` komutunu kullanabilirsiniz. Bir çok açık-kaynak platformu destekliyor; Github, Google Code, BitBucket, ve Launchpad. Üçüncü-parti paketleri kurmak için `go get` komutunu kullanabilirsiniz. Bir çok açık-kaynak platformu destekliyor; GitHub, Google Code, BitBucket, ve Launchpad.
go get github.com/astaxie/beedb go get github.com/astaxie/beedb

View File

@@ -43,7 +43,7 @@ Derleyici tarafından oluşturulmuş aşağıdaki dosyaları temizler:
DIR.test(.exe) // go test -c tarafından oluşturulmuş DIR.test(.exe) // go test -c tarafından oluşturulmuş
MAINFILE(.exe) // go build MAINFILE.go tarafından oluşturulmuş MAINFILE(.exe) // go build MAINFILE.go tarafından oluşturulmuş
Projelerimi Github'a göndermeden önce genellikle bu komutu çalıştırırım. Yereldeki testler için önemli, ama sürüm takip için gereksiz dosyalar. Projelerimi GitHub'a göndermeden önce genellikle bu komutu çalıştırırım. Yereldeki testler için önemli, ama sürüm takip için gereksiz dosyalar.
## go fmt ## go fmt
@@ -56,10 +56,10 @@ Projelerimi Github'a göndermeden önce genellikle bu komutu çalıştırırım.
## go get ## go get
Bu komut üçüncü parti paketleri almanızı sağlar. Şuanda; BitBucket, Github, Google Code ve Launchpad desteği sunuyor. Bu komutu çalıştırdığımızda iki şey yapılıyor. Birincisi Go kaynak kodunu indiriyor, ikinci olarakta `go install` komutunu çalıştırıyor. Bu komutu çalıştırmadan önce, gerekli araçları kurduğunuzdan emin olun. Bu komut üçüncü parti paketleri almanızı sağlar. Şuanda; BitBucket, GitHub, Google Code ve Launchpad desteği sunuyor. Bu komutu çalıştırdığımızda iki şey yapılıyor. Birincisi Go kaynak kodunu indiriyor, ikinci olarakta `go install` komutunu çalıştırıyor. Bu komutu çalıştırmadan önce, gerekli araçları kurduğunuzdan emin olun.
BitBucket (Mercurial Git) BitBucket (Mercurial Git)
Github (git) GitHub (git)
Google Code (Git, Mercurial, Subversion) Google Code (Git, Mercurial, Subversion)
Launchpad (Bazaar) Launchpad (Bazaar)

View File

@@ -315,7 +315,7 @@ Eclipse'de çok tutulan geliştirme araçlarındandır. Size Eclipse ile nasıl
[http://code.google.com/p/goclipse/wiki/InstallationInstructions](http://code.google.com/p/goclipse/wiki/InstallationInstructions) [http://code.google.com/p/goclipse/wiki/InstallationInstructions](http://code.google.com/p/goclipse/wiki/InstallationInstructions)
3. gocode indirin 3. gocode indirin
Github'dan gocode. GitHub'dan gocode.
https://github.com/nsf/gocode https://github.com/nsf/gocode

View File

@@ -132,14 +132,14 @@ mathapp
## 取得遠端套件 ## 取得遠端套件
go 語言有一個取得遠端套件的工具就是`go get`,目前 go get 支援多數開源社群(例如:github、googlecode、bitbucket、Launchpad) go 語言有一個取得遠端套件的工具就是`go get`,目前 go get 支援多數開源社群(例如:GitHub、googlecode、bitbucket、Launchpad)
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
>go get -u 參數可以自動更新套件,而且當 go get 的時候會自動取得該套件依賴的其他第三方套件 >go get -u 參數可以自動更新套件,而且當 go get 的時候會自動取得該套件依賴的其他第三方套件
透過這個命令可以取得相應的原始碼,對應的開源平臺採用不同的原始碼控制工具,例如 github 採用 git、googlecode 採用 hg所以要想取得這些原始碼必須先安裝相應的原始碼控制工具 透過這個命令可以取得相應的原始碼,對應的開源平臺採用不同的原始碼控制工具,例如 GitHub 採用 git、googlecode 採用 hg所以要想取得這些原始碼必須先安裝相應的原始碼控制工具
透過上面取得的程式碼在我們本地的原始碼相應的程式碼結構如下 透過上面取得的程式碼在我們本地的原始碼相應的程式碼結構如下

View File

@@ -71,7 +71,7 @@
MAINFILE(.exe) 由 go build MAINFILE.go 產生 MAINFILE(.exe) 由 go build MAINFILE.go 產生
*.so 由 SWIG 產生 *.so 由 SWIG 產生
我一般都是利用這個命令清除編譯檔案,然後 github 提交原始碼,在本機測試的時候這些編譯檔案都是和系統相關的,但是對於原始碼管理來說沒必要。 我一般都是利用這個命令清除編譯檔案,然後 GitHub 提交原始碼,在本機測試的時候這些編譯檔案都是和系統相關的,但是對於原始碼管理來說沒必要。
$ go clean -i -n $ go clean -i -n
cd /Users/astaxie/develop/gopath/src/mathapp cd /Users/astaxie/develop/gopath/src/mathapp

View File

@@ -221,7 +221,7 @@ VSCode 程式碼設定可用於 Go 擴充套件。這些都可以在使用者的
} }
``` ```
接著安裝相依套件支援(網路不穩定,請直接到 Github [Golang](https://github.com/golang) 下載再移動到相關目錄): 接著安裝相依套件支援(網路不穩定,請直接到 GitHub [Golang](https://github.com/golang) 下載再移動到相關目錄):
```Go ```Go
go get -u -v github.com/nsf/gocode go get -u -v github.com/nsf/gocode
@@ -278,7 +278,7 @@ go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
## Atom ## Atom
Atom 是 Github 基於 Electron 和 web 技術建構的開源編輯器, 是一款很漂亮強大的編輯器缺點是速度比較慢。 Atom 是 GitHub 基於 Electron 和 web 技術建構的開源編輯器, 是一款很漂亮強大的編輯器缺點是速度比較慢。
首先要先安裝下 Atom下載地址: https://atom.io/ 首先要先安裝下 Atom下載地址: https://atom.io/
@@ -564,7 +564,7 @@ Eclipse 也是非常常用的開發利器,以下介紹如何使用 Eclipse 來
3. 下載 gocode用於 go 的程式碼自動完成提示 3. 下載 gocode用於 go 的程式碼自動完成提示
gocode 的 github 地址: gocode 的 GitHub 地址:
https://github.com/nsf/gocode https://github.com/nsf/gocode

View File

@@ -13,7 +13,7 @@ Go 實現的支援 PostgreSQL 的驅動也很多,因為國外很多人在開
- https://github.com/jbarham/gopgsqldriver 支援 database/sql 驅動,純 Go 寫的 - https://github.com/jbarham/gopgsqldriver 支援 database/sql 驅動,純 Go 寫的
- https://github.com/lxn/go-pgsql 支援 database/sql 驅動,純 Go 寫的 - https://github.com/lxn/go-pgsql 支援 database/sql 驅動,純 Go 寫的
在下面的範例中我採用了第一個驅動,因為它目前使用的人最多,在 github 上也比較活躍。 在下面的範例中我採用了第一個驅動,因為它目前使用的人最多,在 GitHub 上也比較活躍。
## 範例程式碼 ## 範例程式碼
資料庫建表語句: 資料庫建表語句:

View File

@@ -1,5 +1,5 @@
# 13.6 小結 # 13.6 小結
這一章我們主要介紹了如何實現一個基礎的 Go 語言框架,框架包含有路由設計,由於 Go 內建的 http 套件中路由的一些不足點,我們設計了動態路由規則,然後介紹了 MVC 模式中的 Controller 設計controller 實現了 REST 的實現,這個主要思路來源於 tornado 框架,然後設計實現了範本的 layout 以及自動化渲染等技術,主要採用了 Go 內建的範本引擎,最後我們介紹了一些輔助的日誌、配置等資訊的設計,透過這些設計我們實現了一個基礎的框架 beego目前該框架已經開源在 github最後我們透過 beego 實現了一個部落格系統,透過範例程式碼詳細的展現了如何快速的開發一個站點。 這一章我們主要介紹了如何實現一個基礎的 Go 語言框架,框架包含有路由設計,由於 Go 內建的 http 套件中路由的一些不足點,我們設計了動態路由規則,然後介紹了 MVC 模式中的 Controller 設計controller 實現了 REST 的實現,這個主要思路來源於 tornado 框架,然後設計實現了範本的 layout 以及自動化渲染等技術,主要採用了 Go 內建的範本引擎,最後我們介紹了一些輔助的日誌、配置等資訊的設計,透過這些設計我們實現了一個基礎的框架 beego目前該框架已經開源在 GitHub最後我們透過 beego 實現了一個部落格系統,透過範例程式碼詳細的展現了如何快速的開發一個站點。
## links ## links
* [目錄](<preface.md>) * [目錄](<preface.md>)

View File

@@ -2,7 +2,7 @@
在開發 Web 應用過程中,使用者認證是開發者經常遇到的問題,使用者登入、註冊、登出等操作,而一般認證也分為三個方面的認證 在開發 Web 應用過程中,使用者認證是開發者經常遇到的問題,使用者登入、註冊、登出等操作,而一般認證也分為三個方面的認證
- HTTP Basic 和 HTTP Digest 認證 - HTTP Basic 和 HTTP Digest 認證
- 第三方整合認證QQ、微博、豆瓣、OPENID、google、github、facebook 和 twitter 等 - 第三方整合認證QQ、微博、豆瓣、OPENID、google、GitHub、facebook 和 twitter 等
- 自訂的使用者登入、註冊、登出,一般都是基於 session、cookie 認證 - 自訂的使用者登入、註冊、登出,一般都是基於 session、cookie 認證
beego 目前沒有針對這三種方式進行任何形式的整合,但是可以充分的利用第三方開源函式庫來實現上面的三種方式的使用者認證,不過後續 beego 會對前面兩種認證逐步整合。 beego 目前沒有針對這三種方式進行任何形式的整合,但是可以充分的利用第三方開源函式庫來實現上面的三種方式的使用者認證,不過後續 beego 會對前面兩種認證逐步整合。
@@ -59,7 +59,7 @@ oauth 和 oauth2 是目前比較流行的兩種認證方式,還好第三方有
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
``` ```
下面程式碼示範了如何把該函式庫引入 beego 中從而實現 oauth 的認證,這裡以 github 為例示範: 下面程式碼示範了如何把該函式庫引入 beego 中從而實現 oauth 的認證,這裡以 GitHub 為例示範:
1. 新增兩條路由 1. 新增兩條路由
@@ -148,13 +148,13 @@ func (this *PageController) Get() {
![](images/14.4.github2.png) ![](images/14.4.github2.png)
圖 14.5 點選登入按鈕後顯示 github 的授權頁 圖 14.5 點選登入按鈕後顯示 GitHub 的授權頁
然後點選 Authorize app 就出現如下介面: 然後點選 Authorize app 就出現如下介面:
![](images/14.4.github3.png) ![](images/14.4.github3.png)
圖 14.6 授權登入之後顯示的取得到的 github 資訊頁 圖 14.6 授權登入之後顯示的取得到的 GitHub 資訊頁
## 自訂認證 ## 自訂認證
自訂的認證一般都是和 session 結合驗證的,如下程式碼來源於一個基於 beego 的開源部落格: 自訂的認證一般都是和 session 結合驗證的,如下程式碼來源於一個基於 beego 的開源部落格:

View File

@@ -11,7 +11,7 @@ import (
"strings" "strings"
) )
// 开发者 github token // 开发者 GitHub token
const token = "" const token = ""
// 定义一个访问者结构体 // 定义一个访问者结构体

View File

@@ -123,13 +123,13 @@ mathapp
这里我们展示如何编译和安装一个可运行的应用,以及如何设计我们的目录结构。 这里我们展示如何编译和安装一个可运行的应用,以及如何设计我们的目录结构。
## 获取远程包 ## 获取远程包
go语言有一个获取远程包的工具就是`go get`目前go get支持多数开源社区(例如:github、googlecode、bitbucket、Launchpad) go语言有一个获取远程包的工具就是`go get`目前go get支持多数开源社区(例如:GitHub、googlecode、bitbucket、Launchpad)
go get github.com/astaxie/beedb go get github.com/astaxie/beedb
>go get -u 参数可以自动更新包而且当go get的时候会自动获取该包依赖的其他第三方包 >go get -u 参数可以自动更新包而且当go get的时候会自动获取该包依赖的其他第三方包
通过这个命令可以获取相应的源码,对应的开源平台采用不同的源码控制工具,例如github采用git、googlecode采用hg所以要想获取这些源码必须先安装相应的源码控制工具 通过这个命令可以获取相应的源码,对应的开源平台采用不同的源码控制工具,例如GitHub采用git、googlecode采用hg所以要想获取这些源码必须先安装相应的源码控制工具
通过上面获取的代码在我们本地的源码相应的代码结构如下 通过上面获取的代码在我们本地的源码相应的代码结构如下

View File

@@ -70,7 +70,7 @@
MAINFILE(.exe) 由go build MAINFILE.go产生 MAINFILE(.exe) 由go build MAINFILE.go产生
*.so 由 SWIG 产生 *.so 由 SWIG 产生
我一般都是利用这个命令清除编译文件,然后github递交源码在本机测试的时候这些编译文件都是和系统相关的但是对于源码管理来说没必要。 我一般都是利用这个命令清除编译文件,然后GitHub递交源码在本机测试的时候这些编译文件都是和系统相关的但是对于源码管理来说没必要。
$ go clean -i -n $ go clean -i -n
cd /Users/astaxie/develop/gopath/src/mathapp cd /Users/astaxie/develop/gopath/src/mathapp

View File

@@ -218,7 +218,7 @@ vscode代码设置可用于Go扩展。这些都可以在用户的喜好来设置
} }
``` ```
接着安装依赖包支持(网络不稳定,请直接到 Github [Golang](https://github.com/golang) 下载再移动到相关目录): 接着安装依赖包支持(网络不稳定,请直接到 GitHub [Golang](https://github.com/golang) 下载再移动到相关目录):
```Go ```Go
go get -u -v github.com/nsf/gocode go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef go get -u -v github.com/rogpeppe/godef
@@ -273,7 +273,7 @@ go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
## Atom ## Atom
Atom是Github基于Electron和web技术构建的开源编辑器, 是一款很漂亮强大的编辑器缺点是速度比较慢。 Atom是GitHub基于Electron和web技术构建的开源编辑器, 是一款很漂亮强大的编辑器缺点是速度比较慢。
首先要先安装下Atom下载地址: https://atom.io/ 首先要先安装下Atom下载地址: https://atom.io/
@@ -556,7 +556,7 @@ Eclipse也是非常常用的开发利器以下介绍如何使用Eclipse来编
3. 下载gocode用于go的代码补全提示 3. 下载gocode用于go的代码补全提示
gocode的github地址 gocode的GitHub地址
https://github.com/nsf/gocode https://github.com/nsf/gocode

View File

@@ -13,7 +13,7 @@ Go实现的支持PostgreSQL的驱动也很多因为国外很多人在开发
- https://github.com/jbarham/gopgsqldriver 支持database/sql驱动纯Go写的 - https://github.com/jbarham/gopgsqldriver 支持database/sql驱动纯Go写的
- https://github.com/lxn/go-pgsql 支持database/sql驱动纯Go写的 - https://github.com/lxn/go-pgsql 支持database/sql驱动纯Go写的
在下面的示例中我采用了第一个驱动,因为它目前使用的人最多,在github上也比较活跃。 在下面的示例中我采用了第一个驱动,因为它目前使用的人最多,在GitHub上也比较活跃。
## 实例代码 ## 实例代码
数据库建表语句: 数据库建表语句:

View File

@@ -1,5 +1,5 @@
# 13.6 小结 # 13.6 小结
这一章我们主要介绍了如何实现一个基础的Go语言框架框架包含有路由设计由于Go内置的http包中路由的一些不足点我们设计了动态路由规则然后介绍了MVC模式中的Controller设计controller实现了REST的实现这个主要思路来源于tornado框架然后设计实现了模板的layout以及自动化渲染等技术主要采用了Go内置的模板引擎最后我们介绍了一些辅助的日志、配置等信息的设计通过这些设计我们实现了一个基础的框架beego目前该框架已经开源在github最后我们通过beego实现了一个博客系统通过实例代码详细的展现了如何快速的开发一个站点。 这一章我们主要介绍了如何实现一个基础的Go语言框架框架包含有路由设计由于Go内置的http包中路由的一些不足点我们设计了动态路由规则然后介绍了MVC模式中的Controller设计controller实现了REST的实现这个主要思路来源于tornado框架然后设计实现了模板的layout以及自动化渲染等技术主要采用了Go内置的模板引擎最后我们介绍了一些辅助的日志、配置等信息的设计通过这些设计我们实现了一个基础的框架beego目前该框架已经开源在GitHub最后我们通过beego实现了一个博客系统通过实例代码详细的展现了如何快速的开发一个站点。
## links ## links
* [目录](<preface.md>) * [目录](<preface.md>)

View File

@@ -2,7 +2,7 @@
在开发Web应用过程中用户认证是开发者经常遇到的问题用户登录、注册、登出等操作而一般认证也分为三个方面的认证 在开发Web应用过程中用户认证是开发者经常遇到的问题用户登录、注册、登出等操作而一般认证也分为三个方面的认证
- HTTP Basic和 HTTP Digest认证 - HTTP Basic和 HTTP Digest认证
- 第三方集成认证QQ、微博、豆瓣、OPENID、google、github、facebook和twitter等 - 第三方集成认证QQ、微博、豆瓣、OPENID、google、GitHub、facebook和twitter等
- 自定义的用户登录、注册、登出一般都是基于session、cookie认证 - 自定义的用户登录、注册、登出一般都是基于session、cookie认证
beego目前没有针对这三种方式进行任何形式的集成但是可以充分的利用第三方开源库来实现上面的三种方式的用户认证不过后续beego会对前面两种认证逐步集成。 beego目前没有针对这三种方式进行任何形式的集成但是可以充分的利用第三方开源库来实现上面的三种方式的用户认证不过后续beego会对前面两种认证逐步集成。
@@ -56,7 +56,7 @@ oauth和oauth2是目前比较流行的两种认证方式还好第三方有一
github.com/bradrydzewski/go.auth github.com/bradrydzewski/go.auth
``` ```
下面代码演示了如何把该库引入beego中从而实现oauth的认证这里以github为例演示 下面代码演示了如何把该库引入beego中从而实现oauth的认证这里以GitHub为例演示
1. 添加两条路由 1. 添加两条路由
```Go ```Go
@@ -142,13 +142,13 @@ func (this *PageController) Get() {
![](images/14.4.github2.png?raw=true) ![](images/14.4.github2.png?raw=true)
图14.5 点击登录按钮后显示github的授权页 图14.5 点击登录按钮后显示GitHub的授权页
然后点击Authorize app就出现如下界面 然后点击Authorize app就出现如下界面
![](images/14.4.github3.png?raw=true) ![](images/14.4.github3.png?raw=true)
图14.6 授权登录之后显示的获取到的github信息页 图14.6 授权登录之后显示的获取到的GitHub信息页
## 自定义认证 ## 自定义认证
自定义的认证一般都是和session结合验证的如下代码来源于一个基于beego的开源博客 自定义的认证一般都是和session结合验证的如下代码来源于一个基于beego的开源博客

View File

@@ -11,7 +11,7 @@ import (
"strings" "strings"
) )
// 开发者 github token // 开发者 GitHub token
const token = "" const token = ""
// 定义一个访问者结构体 // 定义一个访问者结构体