返回课程
AI017 专业级

用Go编程入门

一门适合初学者的实践性课程,介绍Go编程语言。课程以太空探索为主题,分为多个小而易管理的章节,涵盖命令式编程、类型、函数、方法、集合、状态以及并发编程。

4.9
24.0h
749 名学生
8 lessons
0 点赞
人工智能
开始学习

课程概述

📚 内容概要

一门面向初学者、注重实践的 Go 编程语言入门课程。课程采用太空探索主题,分为多个小而易管理的章节,涵盖命令式编程、类型、函数、方法、集合、状态以及并发。

通过简短的课程和七个太空探索主题的综合项目,发现使用 Go 编程的乐趣。

作者: Nathan Youngman,Roger Peppé

致谢: Jennifer Stout,Marina Michaels,Matthew Merkes,Joel Kotarski,Aleksandar Dragosavljević,Renée French,Olga Shalakhina,Erick Zelaya,April Milne,Monica Kamsvaag。

🎯 学习目标

  1. 定义 Go 编程语言及其主要应用场景。
  2. 解释 Go 编译器的作用及其相较于解释器的优势。
  3. 熟练使用 Go Playground 来编写、编译并运行代码。
  4. 正确使用强制性的“唯一正确花括号风格”来组织 Go 代码,避免语法错误。
  5. 使用多种变量声明方式和算术赋值运算符来管理数据。
  6. 生成伪随机数,并通过分支结构和逻辑运算符实现条件逻辑。
  7. 使用 float32float64 声明并格式化浮点变量,控制其宽度和精度。
  8. 识别并缓解由浮点数精度误差和整数溢出引起的错误。
  9. 利用 big 包和无类型常量处理超出标准位宽限制的大数值。
  10. 使用参数、实参和可变参数语法定义并调用函数。

课程

Lesson

This lesson introduces Go as a high-performance, open-source language designed for cloud-native infrastructure and large-scale software engineering. Students will explore Go's core pillars of simplicity, efficiency, and reliability, and learn how its compiler facilitates error detection and maintainable code for complex distributed systems.

This lesson introduces the fundamentals of imperative programming in Go, focusing on the mandatory main package and func main() entry point. Students will also learn the importance of Go’s "One True Brace Style" and how the compiler's automatic semicolon insertion rules dictate specific syntax requirements.

This lesson explores the limitations of binary floating-point arithmetic in Go, explaining why decimal fractions like 0.1 cannot be represented precisely due to base-2 conversion errors. Students will learn to navigate the trade-offs between float32 and float64, emphasizing the importance of avoiding floating-point types for financial calculations and using appropriate precision for scientific data.

This lesson explores the principles of modularity in Go, focusing on how functions, abstraction, and the DRY (Don't Repeat Yourself) principle improve code maintainability and reduce complexity. Students will learn to define clear module boundaries and interfaces to build robust, scalable software systems.

This lesson introduces arrays in Go as fixed-length, type-specific collections used to manage bulk data efficiently. Students will learn how to use composite literals for initialization, navigate zero-based indices, and understand the importance of memory safety to avoid runtime panics.

This lesson introduces Go structures (structs) as a method for grouping disparate data types into cohesive, atomic units for better organization. Students will learn to define and manipulate these structures to manage complex telemetry data, such as Martian habitat coordinates and rover status, more effectively than with individual variables.

This lesson explores the concept of indirection in Go, focusing on how pointers store memory addresses to manage shared data efficiently. Students will learn to use the address operator (&) and dereference operator (*) to manipulate data, while applying these concepts to build performant, shared-state structures like a Sudoku validator.

This lesson explores concurrency in Go, focusing on using goroutines to manage independent tasks and synchronization tools like mutexes and select statements. Students will learn how to handle non-deterministic execution and implement robust worker patterns for multi-agent systems.