From 339e056987ac47660b784aee96d24e0d5e819b46 Mon Sep 17 00:00:00 2001 From: Slava Zgordan Date: Sun, 19 Jul 2015 06:23:31 +0200 Subject: [PATCH] 01.0 is ready --- ru/01.1.md | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ ru/preface.md | 96 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 ru/01.1.md create mode 100644 ru/preface.md diff --git a/ru/01.1.md b/ru/01.1.md new file mode 100644 index 00000000..eac6c9e7 --- /dev/null +++ b/ru/01.1.md @@ -0,0 +1,121 @@ +# 1.1 Installation + +## Three ways to install Go + +There are many ways to configure the Go development environment on your computer, and you can choose whichever one you like. The three most common ways are as follows. + + +- Official installation packages. + - The Go team provides convenient installation packages in Windows, Linux, Mac and other operating systems. This is probably the easiest way to get started. +- Install it yourself from source code. + - Popular with developers who are familiar with Unix-like systems. +- Using third-party tools. + - There are many third-party tools and package managers for installing Go, like apt-get in Ubuntu and homebrew for Mac. + +In case you want to install more than one version of Go on a computer, you should take a look at a tool called [GVM](https://github.com/moovweb/gvm). It is the best tool I've seen so far for accomplishing this task, otherwise you'd have to deal with it yourself. + +## Install from source code + +Because some parts of Go are written in Plan 9 C and AT&T assembler, you have to install a C compiler before taking the next step. + +On a Mac, if you have installed Xcode, you already have the compiler. + +On Unix-like systems, you need to install gcc or a similar compiler. For example, using the package manager apt-get (included with Ubuntu), one can install the required compilers as follows: + + `sudo apt-get install gcc libc6-dev` + +On Windows, you need to install MinGW in order to install gcc. Don't forget to configure your environment variables after the installation has completed.( ***Everything that looks like this means it's commented by a translator: If you are using 64-bit Windows, you should install the 64-bit version of MinGW*** ) + +At this point, execute the following commands to clone the Go source code and compile it.( ***It will clone the source code to your current directory. Switch your work path before you continue. This may take some time.*** ) + + git clone https://go.googlesource.com/go + cd go/src + ./all.bash + +A successful installation will end with the message "ALL TESTS PASSED." + +On Windows, you can achieve the same by running `all.bat`. + +If you are using Windows, the installation package will set your environment variables automatically. In Unix-like systems, you need to set these variables manually as follows. ( ***If your Go version is greater than 1.0, you don't have to set $GOBIN, and it will automatically be related to your $GOROOT/bin, which we will talk about in the next section***) + + export GOROOT=$HOME/go + export GOBIN=$GOROOT/bin + export PATH=$PATH:$GOROOT/bin + +If you see the following information on your screen, you're all set. + +![](images/1.1.mac.png?raw=true) + +Figure 1.1 Information after installing from source code + +Once you see the usage information of Go, it means you have successfully installed Go on your computer. If it says "no such command", check that your $PATH environment variable contains the installation path of Go. + +## Using the standard installation packages + +Go has one-click installation packages for every supported operating system. These packages will install Go in `/usr/local/go` (`c:\Go` in Windows) by default. Of course this can be modified, but you also need to change all the environment variables manually as I've shown above. + +### How to check if your operating system is 32-bit or 64-bit? + +Our next step depends on your operating system type, so we have to check it before we download the standard installation packages. + +If you are using Windows, press `Win+R` and then run the command tool. Type the `systeminfo` command and it will show you some useful system information. Find the line that says "system type" -if you see "x64-based PC" that means your operating system is 64-bit, 32-bit otherwise. + +I strongly recommend downloading the 64-bit package if you are a Mac user, as Go no longer supports pure 32-bit processors on Mac OSX. + +Linux users can type `uname -a` in the terminal to see system information. +A 64-bit operating system will show the following: + + x86_64 x86_64 x86_64 GNU/Linux + // some machines such as Ubuntu 10.04 will show as following + x86_64 GNU/Linux + +32-bit operating systems instead show: + + i686 i686 i386 GNU/Linux + +### Mac + +Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` for 32-bit systems and `go1.4.2.darwin-amd64.pkg` for 64-bit systems. Going all the way to the end by clicking "next", `~/go/bin` will be added to your system's $PATH after you finish the installation. Now open the terminal and type `go`. You should see the same output shown in igure 1.1. + +### Linux + +Go to the [download page](https://golang.org/dl/), choose `go1.4.2.linux-386.tar.gz` for 32-bit systems and `go1.4.2.linux-amd64.tar.gz` for 64-bit systems. Suppose you want to install Go in the `$GO_INSTALL_DIR` path. Uncompress the `tar.gz` to your chosen path using the command `tar zxvf go1.4.2.linux-amd64.tar.gz -C $GO_INSTALL_DIR`. Then set your $PATH with the following: `export PATH=$PATH:$GO_INSTALL_DIR/go/bin`. Now just open the terminal and type `go`. You should now see the same output displayed in figure 1.1. + +### Windows + +Go to the [download page](https://golang.org/dl/), choose `go1.4.2.windows-386.msi` for 32-bit systems and `go1.4.2.windows-amd64.msi` for 64-bit systems. Going all the way to the end by clicking "next", `c:/go/bin` will be added to `path`. Now just open a command line window and type `go`. You should now see the same output displayed in figure 1.1. + +## Use third-party tools + +### GVM + +GVM is a Go multi-version control tool developed by a third-party, like rvm for ruby. It's quite easy to use. Install gvm by typing the following commands in your terminal: + + bash < <(curl -s -S -L https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer) + +Then we install Go using the following commands: + + gvm install go1.4.2 + gvm use go1.4.2 + +After the process has finished, you're all set. + +### apt-get + +Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` to manage packages. We can install Go using the following commands. + + sudo add-apt-repository ppa:gophers/go + sudo apt-get update + sudo apt-get install golang-stable + +### Homebrew + +Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go. + + brew install go + +## Links + +- [Directory](preface.md) +- Previous section: [Go environment configuration](01.0.md) +- Next section: [$GOPATH and workspace](01.2.md) diff --git a/ru/preface.md b/ru/preface.md new file mode 100644 index 00000000..3f97cd99 --- /dev/null +++ b/ru/preface.md @@ -0,0 +1,96 @@ +- 1.[Настройка среды разработки на Go](01.0.md) + - 1.1. [Установка](01.1.md) + - 1.2. [$GOPATH и рабочая директория](01.2.md) + - 1.3. [Команды Go](01.3.md) + - 1.4. [Go development tools](01.4.md) + - 1.5. [Summary](01.5.md) +- 2.[Go basic knowledge](02.0.md) + - 2.1. ["Hello, Go"](02.1.md) + - 2.2. [Go foundation](02.2.md) + - 2.3. [Control statements and functions](02.3.md) + - 2.4. [struct](02.4.md) + - 2.5. [Object-oriented](02.5.md) + - 2.6. [interface](02.6.md) + - 2.7. [Concurrency](02.7.md) + - 2.8. [Summary](02.8.md) +- 3.[Web foundation](03.0.md) + - 3.1. [Web working principles](03.1.md) + - 3.2. [Build a simple web server](03.2.md) + - 3.3. [How Go works with web](03.3.md) + - 3.4. [Get into http package](03.4.md) + - 3.5. [Summary](03.5.md) +- 4.[User form](04.0.md) + - 4.1. [Process form inputs](04.1.md) + - 4.2. [Verification of inputs](04.2.md) + - 4.3. [Cross site scripting](04.3.md) + - 4.4. [Duplicate submissions](04.4.md) + - 4.5. [File upload](04.5.md) + - 4.6. [Summary](04.6.md) +- 5.[Database](05.0.md) + - 5.1. [database/sql interface](05.1.md) + - 5.2. [MySQL](05.2.md) + - 5.3. [SQLite](05.3.md) + - 5.4. [PostgreSQL](05.4.md) + - 5.5. [Develop ORM based on beedb](05.5.md) + - 5.6. [NoSQL database](05.6.md) + - 5.7. [Summary](05.7.md) +- 6.[Data storage and session](06.0.md) + - 6.1. [Session and cookies](06.1.md) + - 6.2. [How to use session in Go](06.2.md) + - 6.3. [Session storage](06.3.md) + - 6.4. [Prevent hijack of session](06.4.md) + - 6.5. [Summary](06.5.md) +- 7.[Text files](07.0.md) + - 7.1. [XML](07.1.md) + - 7.2. [JSON](07.2.md) + - 7.3. [Regexp](07.3.md) + - 7.4. [Templates](07.4.md) + - 7.5. [Files](07.5.md) + - 7.6. [Strings](07.6.md) + - 7.7. [Summary](07.7.md) +- 8.[Web services](08.0.md) + - 8.1. [Sockets](08.1.md) + - 8.2. [WebSocket](08.2.md) + - 8.3. [REST](08.3.md) + - 8.4. [RPC](08.4.md) + - 8.5. [Summary](08.5.md) +- 9.[Security and encryption](09.0.md) + - 9.1. [CSRF attacks](09.1.md) + - 9.2. [Filter inputs](09.2.md) + - 9.3. [XSS attacks](09.3.md) + - 9.4. [SQL injection](09.4.md) + - 9.5. [Password storage](09.5.md) + - 9.6. [Encrypt and decrypt data](09.6.md) + - 9.7. [Summary](09.7.md) +- 10.[Internationalization and localization](10.0.md) + - 10.1 [Time zone](10.1.md) + - 10.2 [Localized resources](10.2.md) + - 10.3 [International sites](10.3.md) + - 10.4 [Summary](10.4.md) +- 11.[Error handling, debugging and testing](11.0.md) + - 11.1. [Error handling](11.1.md) + - 11.2. [Debugging by using GDB](11.2.md) + - 11.3. [Write test cases](11.3.md) + - 11.4. [Summary](11.4.md) +- 12.[Deployment and maintenance](12.0.md) + - 12.1. [Logs](12.1.md) + - 12.2. [Errors and crashes](12.2.md) + - 12.3. [Deployment](12.3.md) + - 12.4. [Backup and recovery](12.4.md) + - 12.5. [Summary](12.5.md) +- 13.[Build a web framework](13.0.md) + - 13.1. [Project program](13.1.md) + - 13.2. [Customized routers](13.2.md) + - 13.3. [Design controllers](13.3.md) + - 13.4. [Logs and configurations](13.4.md) + - 13.5. [Add, delete and update blogs](13.5.md) + - 13.6. [Summary](13.6.md) +- 14.[Develop web framework](14.0.md) + - 14.1. [Static files](14.1.md) + - 14.2. [Session](14.2.md) + - 14.3. [Form](14.3.md) + - 14.4. [User validation](14.4.md) + - 14.5. [Multi-language support](14.5.md) + - 14.6. [pprof](14.6.md) + - 14.7. [Summary](14.7.md) +- Appendix A [References](ref.md)