mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-11 23:08:34 +08:00
add 04.2.md translate for ch 4.2
This commit is contained in:
6
eBook/examples/chapter_4/alias.go
Normal file
6
eBook/examples/chapter_4/alias.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package main
|
||||
import fm “fmt” // alias3
|
||||
|
||||
func main() {
|
||||
fm.Println(“hello, world”)
|
||||
}
|
29
eBook/examples/chapter_4/gotemplate.go
Normal file
29
eBook/examples/chapter_4/gotemplate.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
“fmt”
|
||||
)
|
||||
|
||||
const c = “C”
|
||||
|
||||
var v int = 5
|
||||
|
||||
type T struct{}
|
||||
|
||||
func init() { // initialization of package
|
||||
}
|
||||
|
||||
func main() {
|
||||
var a int
|
||||
Func1()
|
||||
// ...
|
||||
fmt.Println(a)
|
||||
}
|
||||
|
||||
func (t T) Method1() {
|
||||
//...
|
||||
}
|
||||
|
||||
func Func1() { // exported function Func1
|
||||
//...
|
||||
}
|
9
eBook/examples/chapter_4/hello_world.go
Normal file
9
eBook/examples/chapter_4/hello_world.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// hello_world.go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello, world")
|
||||
}
|
||||
|
8
eBook/examples/chapter_4/hello_world2.go
Normal file
8
eBook/examples/chapter_4/hello_world2.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
import “fmt” // Package implementing formatted I/O.
|
||||
|
||||
func main() {
|
||||
fmt.Printf(“Καλημέρα κόσμε; or こんにちは 世界\n”)
|
||||
}
|
||||
|
Reference in New Issue
Block a user