Format and remove en/01.2.md spaces

This commit is contained in:
vCaesar
2017-06-30 23:44:45 +08:00
parent ab37b3f8f4
commit 9aea3b796f

View File

@@ -34,18 +34,18 @@ Execute following commands. ( ***Now author goes back to talk examples*** )
mkdir mymath
Create a new file called `sqrt.go`, type the following content to your file.
```Go
// Source code of $GOPATH/src/mymath/sqrt.go
package mymath
// Source code of $GOPATH/src/mymath/sqrt.go
package mymath
func Sqrt(x float64) float64 {
z := 0.0
for i := 0; i < 1000; i++ {
z -= (z*z - x) / (2 * x)
}
return z
func Sqrt(x float64) float64 {
z := 0.0
for i := 0; i < 1000; i++ {
z -= (z*z - x) / (2 * x)
}
return z
}
```
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.
## Compile packages
@@ -76,17 +76,17 @@ Write the following content to main.go.
```Go
//$GOPATH/src/mathapp/main.go source code.
package main
import (
"mymath"
"fmt"
)
func main() {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2))
}
//$GOPATH/src/mathapp/main.go source code.
package main
import (
"mymath"
"fmt"
)
func main() {
fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2))
}
```
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
You can use remote packages in the same way that we use local packages.
```Go
import "github.com/astaxie/beedb"
import "github.com/astaxie/beedb"
```
## Directory complete structure