首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Package config handles application configuration.
|
||||
package config
|
||||
|
||||
import "fmt"
|
||||
|
||||
// AppConfig holds the application configuration.
|
||||
var AppConfig struct {
|
||||
Port int
|
||||
Env string
|
||||
}
|
||||
|
||||
// init initializes the configuration.
|
||||
func init() {
|
||||
fmt.Println("Initializing config package...")
|
||||
|
||||
// 模拟从配置文件加载配置
|
||||
AppConfig.Port = 8080
|
||||
AppConfig.Env = "development"
|
||||
|
||||
fmt.Printf("Loaded config: %+v\n", AppConfig)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bulma/init_example/config"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fmt.Println("Initializing main package...")
|
||||
}
|
||||
|
||||
// 包变量初始化
|
||||
var counter = initializeCounter()
|
||||
|
||||
// 初始化函数
|
||||
func init() {
|
||||
fmt.Println("Initializing example package...")
|
||||
}
|
||||
|
||||
// 另一个初始化函数
|
||||
func init() {
|
||||
fmt.Println("Another initialization function...")
|
||||
}
|
||||
|
||||
func initializeCounter() int {
|
||||
fmt.Println("Initializing counter...")
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("Starting application...")
|
||||
fmt.Printf("Server will run on port %d in %s mode\n",
|
||||
config.AppConfig.Port, config.AppConfig.Env)
|
||||
}
|
||||
Reference in New Issue
Block a user