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
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.`
36
36
37
37
(Typically these commands must be run as root or through sudo.)
38
38
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:
40
40
41
-
```export PATH=$PATH:/usr/local/go/bin```
41
+
`export PATH=$PATH:/usr/local/go/bin`
42
42
43
43
44
44
### Installing to a custom location
45
45
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.
47
47
48
48
For example, if you installed Go to your home directory you should add the following commands to $HOME/.profile:
49
49
50
-
```export GOROOT=$HOME/go```
50
+
`export GOROOT=$HOME/go`
51
51
52
-
```export PATH=$PATH:$GOROOT/bin```
52
+
`export PATH=$PATH:$GOROOT/bin`
53
53
54
54
>Note: GOROOT must be set only when installing to a custom location.
55
55
@@ -67,16 +67,16 @@ The Go project provides two installation options for Windows users (besides inst
67
67
68
68
Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c:\Go.
69
69
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.
71
71
72
72
73
73
#### Zip archive
74
74
75
75
Download the zip file and extract it into the directory of your choice (we suggest c:\Go).
76
76
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.
78
78
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.
80
80
81
81
#### Setting environment variables under Windows
82
82
@@ -90,9 +90,9 @@ Create a directory to contain your workspace, `$HOME/work` for example, and set
90
90
91
91
$ export GOPATH=$HOME/work
92
92
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.
94
94
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:
96
96
97
97
package main
98
98
@@ -123,7 +123,7 @@ You should also remove the Go bin directory from your PATH environment variable.
123
123
124
124
### Getting help
125
125
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.
127
127
128
128
The official mailing list for discussion of the Go language is Go Nuts.
Copy file name to clipboardExpand all lines: manuscript/02.5ObjectOriented.md
+3
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Object oriented languages allow programmers to declare a function inside the cla
5
5
## methods
6
6
7
7
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
+
8
9
```golang
9
10
package main
10
11
import"fmt"
@@ -106,6 +107,7 @@ type typeName typeLiteral
106
107
```
107
108
108
109
Examples of customized types:
110
+
109
111
```golang
110
112
type ages int
111
113
@@ -273,6 +275,7 @@ func main() {
273
275
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.
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
+
405
409
```golang
406
410
varxfloat64 = 3.4
407
411
v:= reflect.ValueOf(x)
408
412
v.SetFloat(7.1)
409
413
```
414
+
410
415
Instead, we must use the following code to change the values from reflect types.
0 commit comments