Files
build-web-application-with-…/en/02.8.md
2014-12-14 23:27:42 +08:00

33 lines
1.4 KiB
Markdown

# 2.8 Summary
In this chapter, we mainly introduced the 25 Go keywords. Let's review what they are and what they do.
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
- `var` and `const` are used to define variables and constants.
- `package` and `import` are for package use.
- `func` is used to define functions and methods.
- `return` is used to return values in functions or methods.
- `defer` is used to define defer functions.
- `go` is used to start a new goroutine.
- `select` is used to switch over multiple channels for communication.
- `interface` is used to define interfaces.
- `struct` is used to define special customized types.
- `break`, `case`, `continue`, `for`, `fallthrough`, `else`, `if`, `switch`, `goto` and `default` were introduced in section 2.3.
- `chan` is the type of channel for communication among goroutines.
- `type` is used to define customized types.
- `map` is used to define map which is similar to hash tables in other languages.
- `range` is used for reading data from `slice`, `map` and `channel`.
If you understand how to use these 25 keywords, you've learned a lot of Go already.
## Links
- [Directory](preface.md)
- Previous section: [Concurrency](02.7.md)
- Next chapter: [Web foundation](03.0.md)