```bash
# 创建一个示例程序
mkdir goApp
cd goApp
go mod init goApp
touch main.go
```
```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 {
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() {
}
```
```bash
go build --o app
# 查看帮助
./app --help
# 安装成系统服务并且启动
./app install
```
![](https://www.notion.so/signed/https:%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F2864fb08-18ad-4e03-9e5e-263e375fb57c%2FUntitled.png)
有疑问加站长微信联系(非本文作者)