-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
63 lines (51 loc) · 1.15 KB
/
main.go
File metadata and controls
63 lines (51 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import "fmt"
type Person struct {
Name string
Age int
}
func calculate(x, y int) int {
result := x*y + 10
return result
}
func main() {
// 基本类型变量
count := 5
price := 29.99
message := "Hello, Debug!"
isActive := true
// 结构体变量
person := Person{
Name: "Alice",
Age: 25,
}
// 数组和切片
numbers := [3]int{10, 20, 30}
names := []string{"Alice", "Bob", "Charlie"}
// map
scores := map[string]int{
"Math": 90,
"English": 85,
"Science": 95,
}
fmt.Println("程序开始执行...")
// 在这里设置断点!
for i := 0; i < count; i++ {
current := i * 10
temp := calculate(i, count)
fmt.Printf("循环 i=%d, current=%d, temp=%d\n", i, current, temp)
// 修改变量值(可以在调试时观察)
if i == 2 {
price = 39.99
person.Age = 30
scores["Math"] = 95
}
}
fmt.Println("所有变量值:")
fmt.Printf("count: %d, price: %.2f, message: %s, isActive: %t\n",
count, price, message, isActive)
fmt.Printf("person: %+v\n", person)
fmt.Printf("numbers: %v, names: %v\n", numbers, names)
fmt.Printf("scores: %v\n", scores)
// 第三次提交 这个多写个注释测试
}