You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: de/09.4.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ If the user inputs a user name or password as:
32
32
33
33
Then our SQL becomes the following:
34
34
35
-
SELECT * FROM user WHERE username='myuser' or 'foo'=='foo' --'' AND password='xxx'
35
+
SELECT * FROM user WHERE username='myuser' or 'foo' = 'foo' --'' AND password='xxx'
36
36
37
37
In SQL, anything after `--` is a comment. Thus, inserting the `--` as the attacker did above alters the query in a fatal way, allowing an attacker to successfully login as a user without a valid password.
Copy file name to clipboardExpand all lines: en/01.1.md
+15-12
Original file line number
Diff line number
Diff line change
@@ -76,15 +76,15 @@ A 64-bit operating system will show the following:
76
76
77
77
### Mac
78
78
79
-
Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` for 32-bit systems and `go1.7.4.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 figure 1.1.
79
+
Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg`(The later version has no 32-bit download.)for 32-bit systems and `go1.8.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 figure 1.1.
80
80
81
81
### Linux
82
82
83
-
Go to the [download page](https://golang.org/dl/), choose `go1.7.4.linux-386.tar.gz` for 32-bit systems and `go1.7.4.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.7.4.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.
83
+
Go to the [download page](https://golang.org/dl/), choose `go1.8.linux-386.tar.gz` for 32-bit systems and `go1.8.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.8.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.
84
84
85
85
### Windows
86
86
87
-
Go to the [download page](https://golang.org/dl/), choose `go1.7.4.windows-386.msi` for 32-bit systems and `go1.7.4.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.
87
+
Go to the [download page](https://golang.org/dl/), choose `go1.8.windows-386.msi` for 32-bit systems and `go1.8.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.
88
88
89
89
## Use third-party tools
90
90
@@ -96,8 +96,8 @@ GVM is a Go multi-version control tool developed by a third-party, like rvm for
96
96
97
97
Then we install Go using the following commands:
98
98
99
-
gvm install go1.7.4
100
-
gvm use go1.7.4
99
+
gvm install go1.8
100
+
gvm use go1.8
101
101
102
102
After the process has finished, you're all set.
103
103
@@ -109,16 +109,19 @@ Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` t
sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local
121
117
118
+
# Go environment
119
+
export GOROOT=/usr/local/go
120
+
export GOBIN=$GOROOT/bin
121
+
export PATH=$PATH:$GOBIN
122
+
export GOPATH=HOME/gopath
123
+
```
124
+
Starting from go 1.8,The GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows.
122
125
### Homebrew
123
126
124
127
Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go.
Copy file name to clipboardExpand all lines: en/01.2.md
+10-5
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,17 @@
4
4
5
5
Go takes a unique approach to manage the code files with the introduction of a `$GOPATH` directory which contains all the go code in the machine. Note that this is different from the `$GOROOT` environment variable which states where go is installed on the machine. We have to define the $GOPATH variable before using the language, in *nix systems there is a file called `.bashrc` we need to append the below export statement to the file. The concept behind gopath is a novel one, where we can link to any go code at any instant of time without ambiguity.
6
6
7
+
Starting from go 1.8, the GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows.
8
+
7
9
In Unix-like systems, the variable should be used like this:
8
10
9
11
export GOPATH=/home/apple/mygo
10
12
11
13
In Windows, you need to create a new environment variable called GOPATH, then set its value to `c:\mygo`( ***This value depends on where your workspace is located*** )
12
14
13
-
It's OK to have more than one path (workspace) in $GOPATH, but remember that you have to use `:`(`;` in Windows) to break them up. At this point, `go get` will save the content to your first path in $GOPATH. So it is highly recommended to not have multiples versions, the worst case is to create a folder by the name of your project right inside $GOPATH, it breaks everything that the creators were wishing to change in programming with the creation of go language because when you create a folder inside $GOPATH you will reference your packages as directly as <packagename>, and this breaks all the applications which will import your package because the `go get` won't find your package anywhere. So please follow conventions, there is a reason conventions are created
15
+
It's OK to have more than one path (workspace) in $GOPATH, but remember that you have to use `:`(`;` in Windows) to break them up. At this point, `go get` will save the content to your first path in $GOPATH. It is highly recommended to not have multiples versions, the worst case is to create a folder by the name of your project right inside $GOPATH, it breaks everything that the creators were wishing to change in programming with the creation of go language because when you create a folder inside $GOPATH you will reference your packages as directly as <packagename>, and this breaks all the applications which will import your package because the `go get` won't find your package. Please follow conventions, there is a reason conventions are created.
14
16
15
-
In $GOPATH, you must have three folders as follows.
17
+
In $GOPATH, you must have three folders as follows:
16
18
17
19
-`src` for source files whose suffix is .go, .c, .g, .s.
18
20
-`pkg` for compiled files whose suffix is .a.
@@ -72,6 +74,8 @@ Create a new application package called `mathapp`.
72
74
73
75
Write the following content to main.go.
74
76
77
+
```Go
78
+
75
79
//$GOPATH/src/mathapp/main.go source code.
76
80
package main
77
81
@@ -83,7 +87,8 @@ Write the following content to main.go.
To compile this application, you need to switch to the application directory, which in this case is `$GOPATH/src/mathapp`, then execute the `go install` command. Now you should see an executable file called `mathapp` was generated in the directory `$GOPATH/bin/`. To run this program, use the `./mathapp` command. You should see the following content in your terminal.
88
93
89
94
Hello world. Sqrt(2) = 1.414213562373095
@@ -114,9 +119,9 @@ After executing the above commands, the directory structure should look like fol
114
119
Actually, `go get` clones source code to the $GOPATH/src of the local file system, then executes `go install`.
115
120
116
121
You can use remote packages in the same way that we use local packages.
117
-
122
+
```Go
118
123
import"github.com/astaxie/beedb"
119
-
124
+
```
120
125
## Directory complete structure
121
126
122
127
If you've followed all of the above steps, your directory structure should now look like the following.
Copy file name to clipboardExpand all lines: en/02.1.md
+6-3
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
## What makes Go different from other languages?
2
2
3
3
The Go programming language was created with one goal in mind, to be able to build scalable web-applications for large scale audiences in a large team. So that is the reason they made the language as standardized as possible, hence the `gofmt` tool and the strict usage guidelines to the language was for the sake of not having two factions in the developer base, in other languages there are religious wars on where to keep the opening brace?
4
+
```java
4
5
5
6
publicstaticvoid main() {
6
7
@@ -11,6 +12,7 @@ The Go programming language was created with one goal in mind, to be able to bui
11
12
{
12
13
13
14
}
15
+
```
14
16
or for python should we use 4 spaces or 6 spaces or a tab or two tabs and other user preferences.
15
17
16
18
While this might seem to be a shallow problem at the top, but when the codebase grows and more and more people are working on the same code base, then it is difficult to maintain the code's "beauty", if you know python then you might be aware of PEP8, which is a set of guidelines about how to write elegant code. We live in a world where robots can drive a car, so we shouldn't just write code, we should write elegant code.
@@ -40,15 +42,15 @@ Before we start building an application in Go, we need to learn how to write a s
40
42
According to international practice, before you learn how to program in some languages, you will want to know how to write a program to print "Hello world".
41
43
42
44
Are you ready? Let's Go!
43
-
45
+
```Go
44
46
package main
45
47
46
48
import"fmt"
47
49
48
50
funcmain() {
49
51
fmt.Printf("Hello, world or 你好,世界 or καλημ ́ρα κóσμ or こんにちは世界\n")
50
52
}
51
-
53
+
```
52
54
It prints following information.
53
55
54
56
Hello, world or 你好,世界 or καλημ ́ρα κóσμ or こんにちは世界
@@ -83,10 +85,11 @@ Each go file is in some package, and that package should be a distinct folder in
83
85
the thing here is that when your code is using some static files or something else, then you ought to run the binary from the root of the application as we see in the second line above, I am running the `main` binary *outside* the main package, sometimes you might wonder why your application isn't working then this might be one of the possible problems, please keep this in mind.
84
86
85
87
One thing you will notice here is that go doesn't see to use semi colons to end a statement, well, it does, just there is a minor catch, the programmer isn't expected to put semi colons, the compiler adds semi colons to the gocode when it compiles which is the reason that this (thankfully!) is a syntax error
86
-
88
+
```Go
87
89
funcmain ()
88
90
{
89
91
}
92
+
```
90
93
because the compiler adds a semi colon at the end of `main()` which is a syntax error and as stated above, it helps avoid religious wars, i wish they combine `vim` and `emacs` and create a universal editor which'll help save some more wars! But for now we'll learn Go.
0 commit comments