mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-22 23:12:15 +08:00
docs: HelloWorld
This commit is contained in:
parent
1e4676b7b7
commit
47374638ff
25
base/helloworld/main.go
Normal file
25
base/helloworld/main.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
// 导入语句
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// 函数外只能放置标识符(变量/常量/函数/类型)的声明
|
||||
|
||||
const OS = runtime.GOOS
|
||||
const ARCH = runtime.GOARCH
|
||||
|
||||
// 优先级高于 main, 在每个包初始化完成后自动执行
|
||||
// 通常用于 对变量进行初始化、注册等
|
||||
func init() {
|
||||
fmt.Println("init 初始化")
|
||||
}
|
||||
|
||||
// 程序入口函数
|
||||
func main() {
|
||||
fmt.Println("Hello World!")
|
||||
|
||||
fmt.Printf("操作系统 %s, 系统架构 %s\n", OS, ARCH)
|
||||
}
|
Loading…
Reference in New Issue
Block a user