Merge branch 'master' of ssh://focs.ji.sjtu.edu.cn:2222/FOCS-dev/JOJ3.wiki
commit
58754f3cd8
|
|
@ -80,6 +80,7 @@ There are three kinds of ways to initialize variables:
|
|||
var v1 int = 10 // method 1
|
||||
var v2 = 10 // method 2
|
||||
v3 := 10 // method 3
|
||||
v4 := [3]int{1, 2, 3} //initialize a slice
|
||||
```
|
||||
|
||||
It can be observed that the compiler can deduce the data type automatically. However, when we use **method 3**, the variable should not be declared before, which will contribute to the error.
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
# To_get_start
|
||||
|
||||
## Structure and Compilation
|
||||
Let's first create a file called "Hello_JOJ.go", and write in:
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main(){
|
||||
fmt.Println("Hello "+ "JOJ")
|
||||
}
|
||||
```
|
||||
Observe the structure it is similar to both Python and C++, as it needs to import certain library and need some special package to run the program. We will also see further that the syntax of Go is like the combination of both C++ and Python.
|
||||
|
||||
If you want to run the program, you can either choose to directly run it:
|
||||
```bash
|
||||
$ go run Hello_JOJ.go
|
||||
```
|
||||
or choose to compile it as a binary file:
|
||||
```bash
|
||||
$ go build Hello_JOJ.go
|
||||
$ ./Hello_JOJ
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user