Golang Study Note (Episode 1)
Advantage of Golang
- Effortless Deployment and Execution
- Direct compilation to machine code for streamlined execution.
- Independence from external dependencies ensures a lightweight footprint.
- Straightforward run and deployment process, unlike Java which requires JDK.
- Static Typing
- Compile-time error detection enhances code reliability.
- Robust Concurrency Support
- Intrinsic support for concurrent programming.
- Efficient utilization of multi-core processors.
- Extensive Library Support
- Advanced runtime system scheduling for optimal performance.
- State-of-the-art garbage collection mechanisms.
- Comprehensive suite of standard libraries.
- User-Friendly Learning Curve
- Minimalistic design with only 25 keywords.
- Familiar C-like syntax for easy adaptation.
- Incorporates object-oriented programming principles.
- Cross-platform compatibility broadens usability.
- Widespread Industry Adoption
- Utilized by tech giants like Google, Meta, Tencent, TikTok/Bytedance, and Baidu.
- Popular products like docker, kubernetes
Hello World Demo
Print Hello World
Create a file called helloworld.go
1 | package main // package declaration |
Multiple Import
Multiple libraries can be imported within one single import
1 | package main // package declaration |
Curly Braces Syntax
Note that in Go, the curly braces must be on the same line as the function declaration. The following code example won’t work
1 | // Curly Braces Syntax Error example |
The program will complain as follow
1 | KuroMac:helloworld ziheji$ go run helloworld.go |
Github Repository
The github source code for this note can be found at https://github.com/Kuro1Fury/GolangStudy/tree/main/helloworld
Credit
Thanks for the tutorial 8 小时转职 Golang 工程师(如果你想低成本学习 Go 语言) made by 刘丹冰 Aceld
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment