Skip to content

Commit 6679a28

Browse files
committed
minor updates
1 parent d7695bf commit 6679a28

7 files changed

+31
-15
lines changed

manuscript/0.0installation.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,28 @@ install it from the Components tab of the Downloads preferences panel.
2828
If you are upgrading from an older version of Go you must first remove the existing version.
2929
Linux, Mac OS X, and FreeBSD tarballs
3030

31-
Download the archive and extract it into ```/usr/local```, creating a Go tree in ```/usr/local/go```. For example:
31+
Download the archive and extract it into `/usr/local`, creating a Go tree in `/usr/local/go`. For example:
3232

33-
```tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz```
33+
`tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz`
3434

35-
Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux, the archive you want is called ```go1.2.1.linux-amd64.tar.gz.```
35+
Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.2.1 for 64-bit x86 on Linux, the archive you want is called `go1.2.1.linux-amd64.tar.gz.`
3636

3737
(Typically these commands must be run as root or through sudo.)
3838

39-
Add``` /usr/local/go/bin``` to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile:
39+
Add` /usr/local/go/bin` to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile:
4040

41-
```export PATH=$PATH:/usr/local/go/bin```
41+
`export PATH=$PATH:/usr/local/go/bin`
4242

4343

4444
### Installing to a custom location
4545

46-
The Go binary distributions assume they will be installed in ```/usr/local/go``` (or ```c:\Go``` under Windows), but it is possible to install the Go tools to a different location. In this case you must set the GOROOT environment variable to point to the directory in which it was installed.
46+
The Go binary distributions assume they will be installed in `/usr/local/go` (or `c:\Go` under Windows), but it is possible to install the Go tools to a different location. In this case you must set the GOROOT environment variable to point to the directory in which it was installed.
4747

4848
For example, if you installed Go to your home directory you should add the following commands to $HOME/.profile:
4949

50-
```export GOROOT=$HOME/go```
50+
`export GOROOT=$HOME/go`
5151

52-
```export PATH=$PATH:$GOROOT/bin```
52+
`export PATH=$PATH:$GOROOT/bin`
5353

5454
>Note: GOROOT must be set only when installing to a custom location.
5555
@@ -67,16 +67,16 @@ The Go project provides two installation options for Windows users (besides inst
6767

6868
Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c:\Go.
6969

70-
The installer should put the ```c:\Go\bin``` directory in your PATH environment variable. You may need to restart any open command prompts for the change to take effect.
70+
The installer should put the `c:\Go\bin` directory in your PATH environment variable. You may need to restart any open command prompts for the change to take effect.
7171

7272

7373
#### Zip archive
7474

7575
Download the zip file and extract it into the directory of your choice (we suggest c:\Go).
7676

77-
If you chose a directory other than ```c:\Go```, you must set the GOROOT environment variable to your chosen path.
77+
If you chose a directory other than `c:\Go`, you must set the GOROOT environment variable to your chosen path.
7878

79-
Add the bin subdirectory of your Go root (for example, ```c:\Go\bin```) to your PATH environment variable.
79+
Add the bin subdirectory of your Go root (for example, `c:\Go\bin`) to your PATH environment variable.
8080

8181
#### Setting environment variables under Windows
8282

@@ -90,9 +90,9 @@ Create a directory to contain your workspace, `$HOME/work` for example, and set
9090

9191
$ export GOPATH=$HOME/work
9292

93-
You should put the above command in your shell startup script (`$HOME/.profile` for example) or, if you use Windows, follow the instructions above to set the ```GOPATH``` environment variable on your system.
93+
You should put the above command in your shell startup script (`$HOME/.profile` for example) or, if you use Windows, follow the instructions above to set the `GOPATH` environment variable on your system.
9494

95-
Next, make the directories ```src/github.com/user/hello``` inside your workspace (if you use GitHub, substitute your user name for user), and inside the hello directory create a file named hello.go with the following contents:
95+
Next, make the directories `src/github.com/user/hello` inside your workspace (if you use GitHub, substitute your user name for user), and inside the hello directory create a file named hello.go with the following contents:
9696

9797
package main
9898
@@ -123,7 +123,7 @@ You should also remove the Go bin directory from your PATH environment variable.
123123

124124
### Getting help
125125

126-
For real-time help, ask the helpful gophers in ```#go-nuts``` on the Freenode IRC server.
126+
For real-time help, ask the helpful gophers in `#go-nuts` on the Freenode IRC server.
127127

128128
The official mailing list for discussion of the Go language is Go Nuts.
129129

manuscript/02.4Struct.md

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ There are three more ways to define a struct.
5252
Let's see a complete example.
5353

5454
file: `code/Struct/Book/struct.go`
55+
5556
```golang
5657
package main
5758

@@ -106,6 +107,7 @@ When the embedded field is a struct, all the fields in that struct will implicit
106107
Let's see one example.
107108

108109
file: `code/Struct/Human/human.go`
110+
109111
```golang
110112
package main
111113
import "fmt"

manuscript/02.5ObjectOriented.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Object oriented languages allow programmers to declare a function inside the cla
55
## methods
66

77
We defined a "rectangle" struct and we want to calculate its area. Normally, we would create a function, pass the struct's instance and calculate the area.
8+
89
```golang
910
package main
1011
import "fmt"
@@ -106,6 +107,7 @@ type typeName typeLiteral
106107
```
107108

108109
Examples of customized types:
110+
109111
```golang
110112
type ages int
111113

@@ -273,6 +275,7 @@ func main() {
273275
If we want Employee to have its own method `SayHi`, we can define a method that has the same name in Employee, and it will hide `SayHi` in Human when we call it.
274276

275277
file: `code/ObjectOriented/human/human.go`
278+
276279
```golang
277280
package main
278281
import "fmt"

manuscript/02.6Interface.md

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ type Stringer interface {
205205
This means any type that implements interface Stringer can be passed to fmt.Println as an argument. Let's prove it.
206206

207207
file: `code/Interface/Stringer/stringer.go`
208+
208209
```golang
209210
package main
210211

@@ -252,6 +253,7 @@ If the element is the type that we expect, ok will be true, false otherwise.
252253
Let's use an example to see more clearly.
253254

254255
file: `code/Interface/Person/person.go`
256+
255257
```golang
256258
package main
257259

@@ -393,6 +395,7 @@ v := reflect.ValueOf(i) // get actual value in type i, and use v to change its
393395
```
394396

395397
After that, we can convert the reflected types to get the values that we need.
398+
396399
```golang
397400
var x float64 = 3.4
398401
v := reflect.ValueOf(x)
@@ -402,12 +405,15 @@ fmt.Println("value:", v.Float())
402405
```
403406

404407
Finally, if we want to change the values of the reflected types, we need to make it modifiable. As discussed earlier, there is a difference between pass by value and pass by reference. The following code will not compile.
408+
405409
```golang
406410
var x float64 = 3.4
407411
v := reflect.ValueOf(x)
408412
v.SetFloat(7.1)
409413
```
414+
410415
Instead, we must use the following code to change the values from reflect types.
416+
411417
```golang
412418
var x float64 = 3.4
413419
p := reflect.ValueOf(&x)

manuscript/2.1WebAppDesign.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Login/Sign up.
1717
## The Design
1818

1919
Translating our design to API, we get the following.
20+
2021
| URL | Method | Description |
2122
| ------ | ------ | ------ |
2223
| /add/ | POST | add new task |

manuscript/2.2database.md

+1
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ round-trips to the database.
959959
#Database Encapsulation
960960

961961
We encapsulate our db object inside a struct. We also encapsulate the database actions as shown below
962+
962963
```golang
963964
var database Database
964965

manuscript/3.0templating.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ We have this scenario, we have a range of categories in the navigation drawer an
213213
{{$nav := .Navigation}}
214214
{{ range $index, $cat := .Categories }}
215215
<li class="sidebar-item">
216-
<a href="/category/{{$cat.Name}}" {{ if eq $cat.Name $nav }} class="active" {{end}}>
216+
<a href="/category/{{$cat.Name}}"
217+
{{ if eq $cat.Name $nav }}
218+
class="active"
219+
{{end}} >
217220
<span class="nav-item">
218221
{{$cat.Name}}
219222
</span>

0 commit comments

Comments
 (0)