docs: HelloWorld

This commit is contained in:
Shikong 2021-09-12 16:19:51 +08:00
parent 1e4676b7b7
commit 47374638ff
2 changed files with 28 additions and 0 deletions

25
base/helloworld/main.go Normal file
View 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)
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module skcks.cn/Shikong/golang-study
go 1.16