First time you meet him
package main
import (
"fmt"
)
func main() {
var x string
x = "Hello"
y := "world"
var sentence string = x + ", " + y + "!"
fmt.Println(sentence)
fmt.Printf("%s, %s!", y, x)
}
As you can see, Go is a kind of combination of Python, C++, JavaScript.
package
, have no idea yet.func main() {}
is like C or C++ codes structure, which without;
to determine if a statement was finished.var x string
is like the way of declaring a variable in JavaScript.y := "world"
is like Python, in there, the compiler will automatically figure out the variable type without you to declare.fmt.Println()
is like Python'sprint()
, and revealed the relationship ofClass
andFunction
.
Last updated
Was this helpful?