Skip to content

Commit

Permalink
Add: 07 Chinese version (#136)
Browse files Browse the repository at this point in the history
* Add: 07 Chinese version
  • Loading branch information
xiyichan authored Jan 15, 2023
1 parent 8a91998 commit bd3cb81
Show file tree
Hide file tree
Showing 27 changed files with 668 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
ops, ok, fail := 2350, 543, 433

fmt.Println(
"total:", ops, "- success:", ok, "/", fail,
)

fmt.Printf(
"total: %d - success: %d / %d\n",
ops, ok, fail,
)
}
21 changes: 21 additions & 0 deletions translation/chinese/07-打印/01-介绍/02/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var brand string

// 像这样 "" 引用形式打印字符串
fmt.Printf("%q\n", brand)

brand = "Google"
fmt.Printf("%q\n", brand)
}
26 changes: 26 additions & 0 deletions translation/chinese/07-打印/02-转义序列/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
// 没有换行符
fmt.Println("hihi")

// 使用换行符:
// \n = 转义序列
// \ = 转义字符
fmt.Println("hi\nhi")

// 转义字符:
// \\ = \
// \" = "
fmt.Println("hi\\n\"hi\"")
}
26 changes: 26 additions & 0 deletions translation/chinese/07-打印/03-打印类型/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
// 我正在使用一次声明多个变量,而不是一次声明一个变量
var (
speed int
heat float64
off bool
brand string
)

fmt.Printf("%T\n", speed)
fmt.Printf("%T\n", heat)
fmt.Printf("%T\n", off)
fmt.Printf("%T\n", brand)
}
52 changes: 52 additions & 0 deletions translation/chinese/07-打印/04-编程/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
var (
planet = "venus"
distance = 261
orbital = 224.701
hasLife = false
)

// 全能打印 %v 动词
fmt.Printf("Planet: %v\n", planet)
fmt.Printf("Distance: %v millions kms\n", distance)
fmt.Printf("Orbital Period: %v days\n", orbital)
fmt.Printf("Does %v have life? %v\n", planet, hasLife)

// 参数索引 - 索引从 1 开始
fmt.Printf(
"%v is %v away. Think! %[2]v kms! %[1]v OMG.\n",
planet, distance,
)

// 为什么不使用别的打印词?
// 原因: 有可能因为类型不正确导致报错
//
// fmt.Printf("Planet: %d\n", planet)
// fmt.Printf("Distance: %s millions kms\n", distance)
// fmt.Printf("Orbital Period: %t days\n", orbital)
// fmt.Printf("Does %v has life? %f\n", planet, hasLife)

// 正确的打印动词:
// fmt.Printf("Planet: %s\n", planet)
// fmt.Printf("Distance: %d millions kms\n", distance)
// fmt.Printf("Orbital Period: %f days\n", orbital)
// fmt.Printf("Does %s has life? %t\n", planet, hasLife)

// 更加精确的打印动词
fmt.Printf("Orbital Period: %f days\n", orbital)
fmt.Printf("Orbital Period: %.0f days\n", orbital)
fmt.Printf("Orbital Period: %.1f days\n", orbital)
fmt.Printf("Orbital Period: %.2f days\n", orbital)
}
25 changes: 25 additions & 0 deletions translation/chinese/07-打印/练习/01-print-your-age/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习: 打印你的年来
//
// 使用 Printf 打印你的年龄
//
// 期望输出
// I'm 30 years old.
//
// 注意
// 你应该把你的年龄给程 30 岁
// ---------------------------------------------------------

func main() {
// ?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Printf("I'm %d years old.\n", 30)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习:打印您的名字和姓氏
//
// 使用 Printf 您的名字和姓氏
//
// 期望输出
// My name is Inanc and my lastname is Gumus.
//
// 额外
// 把打印格式声明字符串 (Printf 的第一个参数) 存到一个变量
// 然后传递到 Printf
// ---------------------------------------------------------

func main() {
// 额外: 使用一个变量存打印格式声明字符串

// fmt.Printf("?", ?, ?)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Printf("My name is %s and my lastname is %s.\n", "Inanc", "Gumus")

// 额外
msg := "My name is %s and my lastname is %s.\n"
fmt.Printf(msg, "Inanc", "Gumus")
}
27 changes: 27 additions & 0 deletions translation/chinese/07-打印/练习/03-false-claims/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习: false 声明
//
// 使用 Printf 使用变量打印预期输出
//
// 期望输出
// These are false claims.
// ---------------------------------------------------------

func main() {
// 将注释下的代码去掉注释
// 然后移到你的代码中
// tf := false

// 将你的代码写到下面
// ?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
tf := false
fmt.Printf("These are %t claims.\n", tf)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习:打印温度
//
// 使用 Printf 打印您所在地区的当前温度
//
// 注意
// 不要使用 %v 动词
// 输出不应该是 29.500000
//
// 期望输出
// Temperature is 29.5 degrees.
// ---------------------------------------------------------

func main() {
// ?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Printf("Temperature is %.1f degrees.\n", 29.5)
}
26 changes: 26 additions & 0 deletions translation/chinese/07-打印/练习/05-double-quotes/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习:双引号
//
// 使用 Printf 打印带有双引号的 "hello world"
//(正如你在这里看到的)
//
// 注意
// 输出不应该只是 hello world
//
// 期待输出
// "hello world"
// ---------------------------------------------------------

func main() {
// ?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

import "fmt"

func main() {
fmt.Printf("%q\n", "hello world")
}
22 changes: 22 additions & 0 deletions translation/chinese/07-打印/练习/06-print-the-type/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus

package main

// ---------------------------------------------------------
// 练习:打印字体
//
// 使用 fmt.Printf 打印 3 的类型和值
//
// 期望输出
// Type of 3 is int
// ---------------------------------------------------------

func main() {
// ?
}
Loading

0 comments on commit bd3cb81

Please sign in to comment.