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: en/01.2.md
+22-22
Original file line number
Diff line number
Diff line change
@@ -34,18 +34,18 @@ Execute following commands. ( ***Now author goes back to talk examples*** )
34
34
mkdir mymath
35
35
36
36
Create a new file called `sqrt.go`, type the following content to your file.
37
+
```Go
38
+
// Source code of $GOPATH/src/mymath/sqrt.go
39
+
package mymath
37
40
38
-
// Source code of $GOPATH/src/mymath/sqrt.go
39
-
package mymath
40
-
41
-
func Sqrt(x float64) float64 {
42
-
z := 0.0
43
-
for i := 0; i < 1000; i++ {
44
-
z -= (z*z - x) / (2 * x)
45
-
}
46
-
return z
41
+
funcSqrt(xfloat64) float64 {
42
+
z:=0.0
43
+
fori:=0; i < 1000; i++ {
44
+
z -= (z*z - x) / (2 * x)
47
45
}
48
-
46
+
return z
47
+
}
48
+
```
49
49
Now my package directory has been created and it's code has been written. I recommend that you use the same name for your packages as their corresponding directories, and that the directories contain all of the package source files.
50
50
51
51
## Compile packages
@@ -76,17 +76,17 @@ 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.
@@ -120,7 +120,7 @@ Actually, `go get` clones source code to the $GOPATH/src of the local file syste
120
120
121
121
You can use remote packages in the same way that we use local packages.
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp)ifnotos.path.exists(ipp)elseNone;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read());print('Please restart Sublime Text to finish installation')
123
+
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp)ifnotos.path.exists(ipp)elseNone;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace('','%20')).read());print('Please restart Sublime Text to finish installation')
124
124
```
125
125
126
126
Restart Sublime Text when the installation has finished. You should then find a `Package Control` option in the "Preferences" menu.
0 commit comments