Skip to content

Commit

Permalink
🎉 now you can use --version to print version string
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Jul 29, 2022
1 parent d0853fc commit 5af7432
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ Please visit https://go-file.herokuapp.com/ to have a try yourself.
3. 选择`在此处打开 PowerShell`(如果是 Windows 11 的话则需要先点击`显示更多选项`),
4. 在打开的终端中输入:`./go-file --port 80 --video ./path/to/video`

**使用 Docker 部署:**
1. 拉取镜像:`docker pull justsong/go-file:latest`
2. 运行:`docker -p 3000:3000 run justsong/go-file:latest`

**注意:**
1. 如果主机有多个 ip 地址,请使用 host 参数指定一个其他设备可访问的 ip 地址,如:`go-file.exe --host xxx.xxx.xxx.xxx`,否则二维码将生成错误。
2. 默认配置下访客可以上传和下载文件,可在 `管理` -> `系统设置` 中修改权限配置。
Expand Down
22 changes: 15 additions & 7 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"embed"
"flag"
"fmt"
"github.com/google/uuid"
"os"
"path"
Expand All @@ -11,7 +12,7 @@ import (
)

var StartTime = time.Now()
var Version = "v0.4.2"
var Version = "v0.4.3"
var OptionMap map[string]string

var ItemsPerPage = 10
Expand Down Expand Up @@ -51,11 +52,12 @@ const (
)

var (
Port = flag.Int("port", 3000, "specify the server listening port.")
Host = flag.String("host", "localhost", "the server's ip address or domain")
Path = flag.String("path", "", "specify a local path to public")
VideoPath = flag.String("video", "", "specify a video folder to public")
NoBrowser = flag.Bool("no-browser", false, "open browser or not")
Port = flag.Int("port", 3000, "specify the server listening port.")
Host = flag.String("host", "localhost", "the server's ip address or domain")
Path = flag.String("path", "", "specify a local path to public")
VideoPath = flag.String("video", "", "specify a video folder to public")
NoBrowser = flag.Bool("no-browser", false, "open browser or not")
PrintVersion = flag.Bool("version", false, "print version")
)

// UploadPath Maybe override by ENV_VAR
Expand All @@ -72,6 +74,13 @@ var SessionSecret = uuid.New().String()
var SQLitePath = ".go-file.db"

func init() {
flag.Parse()

if *PrintVersion {
fmt.Println(Version)
os.Exit(0)
}

if os.Getenv("SESSION_SECRET") != "" {
SessionSecret = os.Getenv("SESSION_SECRET")
}
Expand All @@ -84,7 +93,6 @@ func init() {
ImageUploadPath = path.Join(UploadPath, "images")
VideoServePath = UploadPath
}
flag.Parse()
if *Path != "" {
ExplorerRootPath = *Path
}
Expand Down

0 comments on commit 5af7432

Please sign in to comment.