-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (34 loc) · 642 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"log"
"os"
"github.com/spf13/cobra"
"goframe/cmd"
"goframe/cmd/http_serve"
)
var (
// build 时间
BuildTime string
// git commit
Version string
)
var rootCmd = &cobra.Command{
Use: "goframe",
Short: "this is web project",
}
// 注入git版本和编译时间
func init() {
log.Printf("Version: %s", Version)
log.Printf("BuildTime: %s", BuildTime)
}
func main() {
// http web 服务
rootCmd.AddCommand(http_serve.HttpServeCmd)
// 注册全局参数,--env 是什么环境
cmd.RegisterGlobalFlags(rootCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}