Skip to content

Commit

Permalink
支持显示版本 --version
Browse files Browse the repository at this point in the history
  • Loading branch information
hellojukay committed Jan 23, 2022
1 parent 16c9748 commit 5e19e2c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@ import (
"net/http"
"os"
"path/filepath"
"runtime/debug"
)

var dir string
var port string
var version bool

func init() {
flag.StringVar(&port, "p", "8100", "port to serve on")
flag.StringVar(&dir, "path", "./", "the directory of static file to host")
flag.BoolVar(&version, "version", false, "print program version")
flag.Parse()

if version {
info, ok := debug.ReadBuildInfo()
if ok {
println(info.Main.Version, info.Main.Sum)
}
os.Exit(0)
}
if dir == "./" {
dir, _ = os.Getwd()
}
Expand Down

0 comments on commit 5e19e2c

Please sign in to comment.