# 创建一个示例程序
mkdir goApp
cd goApp
go mod init goApp
touch main.go
// main.go
package main
import (
"net/http"
"github.com/sohaha/zlsgo/zcli"
"github.com/sohaha/zlsgo/zlog"
)
var (
debug = zcli.SetVar("debug", "Debug mode").Bool()
)
func main() {
// 设置应用信息
zcli.Logo = `
____ __ ____ __ ____ ____
(__ | ) / ___) / _\( _ ( _ \
/ _// (_/\___ \/ \) __/) __/
(____)____(____/\_/\_(__) (__) `
zcli.Version = "1.0.0"
err := zcli.LaunchServiceRun("ZlsApp", "", run)
if err != nil{
zlog.Error(err)
} else {
stop()
}
}
func run() {
// 设置终端执行参数
isDebug := *debug
if isDebug {
zlog.Dump("开发模式")
}
http.HandleFunc("/", Handler)
http.ListenAndServe(":8888", nil)
}
func Handler(w http.ResponseWriter, r *http.Request) {
}
func stop() {
}
go build --o app
# 查看帮助
./app --help
# 安装成系统服务并且启动
./app install