From 516f2ab8b656b3eef513a0684c856bebed291b7c Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:33:59 +0800 Subject: [PATCH 01/12] =?UTF-8?q?path=5Fshow=20=E7=A7=BB=E5=8A=A8=E8=87=B3?= =?UTF-8?q?main=E5=8F=98=E9=87=8F=EF=BC=9B=E6=A3=80=E6=B5=8Bpath=5Fshow?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webdemo.go | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/webdemo.go b/webdemo.go index e7d36b4..c529acc 100644 --- a/webdemo.go +++ b/webdemo.go @@ -7,6 +7,7 @@ import ( "log" "net" "net/http" + "os" "strconv" "github.com/quic-go/quic-go" @@ -19,21 +20,21 @@ import ( // blue := "\033[34m" // reset := "\033[0m" -// func exit_path(filename string) int { -// _, err := os.Stat(filename) -// if err == nil { -// // fmt.Printf("文件 %s 存在\n", filename) -// return 0 -// } else if os.IsNotExist(err) { -// // fmt.Printf("文件 %s 不存在\n", filename) -// return 1 -// } else { -// // fmt.Printf("检查文件时发生错误: %v\n", err) -// return 2 -// } -// } - -func basicAuth(handler http.Handler, username, password string) http.Handler { +func exit_path(filename string) int { + _, err := os.Stat(filename) + if err == nil { + // fmt.Printf("文件 %s 存在\n", filename) + return 0 + } else if os.IsNotExist(err) { + // fmt.Printf("文件 %s 不存在\n", filename) + return 1 + } else { + // fmt.Printf("检查文件时发生错误: %v\n", err) + return 2 + } +} + +func basicAuth(handler http.Handler, username, password, path string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ip := r.RemoteAddr // 访问的 IP 地址 ua := r.UserAgent() //r.Header.Get("User-Agent") 获取ua头 @@ -45,13 +46,13 @@ func basicAuth(handler http.Handler, username, password string) http.Handler { w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`) w.WriteHeader(http.StatusUnauthorized) fmt.Fprintln(w, "Unauthorized") - log.Printf("\033[31m 非法访问者 %s \033[0m 使用%s 头,%s方式尝试请求文件\033[31m%s\033[0m", ip, ua, r.Method, *path_show+r.URL.Path) + log.Printf("\033[31m 非法访问者 %s \033[0m 使用%s 头,%s方式尝试请求文件\033[31m%s\033[0m", ip, ua, r.Method, path+r.URL.Path) return } else { - log.Printf("\033[32m%s \033[0m使用%s 头,%s方式请求文件%s", ip, ua, r.Method, *path_show+r.URL.Path) + log.Printf("\033[32m%s \033[0m使用%s 头,%s方式请求文件%s", ip, ua, r.Method, path+r.URL.Path) } } else { - log.Printf("\033[33m%s \033[0m使用%s 头,%s方式请求文件%s", ip, ua, r.Method, *path_show+r.URL.Path) + log.Printf("\033[33m%s \033[0m使用%s 头,%s方式请求文件%s", ip, ua, r.Method, path+r.URL.Path) } handler.ServeHTTP(w, r) @@ -135,10 +136,7 @@ func quicgo_ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handl } } -var path_show = flag.String("path", ".", "文件路径") //文件加载路径,绝对路径可以,相对路径也可以,但需要注意加引号 - func main() { - var crtPath = flag.String("crt", "D:/study/ssh-key/webdemo/server.crt", "crt路径") var keyPath = flag.String("key", "D:/study/ssh-key/webdemo/server.key", "key路径") var username = flag.String("u", "", "用户名") //默认用户名admin @@ -146,14 +144,17 @@ func main() { flag.StringVar(&password, "password", "", "密码") //长参数-password flag.StringVar(&password, "p", "", "密码") //短参数-p port := flag.Int("port", 443, "端口") - + var path_show = flag.String("path", ".", "文件路径") //文件加载路径,绝对路径可以,相对路径也可以,但需要注意加引号 flag.Parse() // result1 := exit_path(*crtPath) //crt证书是否存在 // result2 := exit_path(*keyPath) //key密钥是否存在 - + if exit_path(*path_show) != 0 { + log.Println("\033[31m ", *path_show, "\033[0m当前文件(文件夹)路径不存在,请重新输入") + os.Exit(1) + } fileServer := http.FileServer(http.Dir(*path_show)) - authHandler := basicAuth(fileServer, *username, password) + authHandler := basicAuth(fileServer, *username, password, *path_show) log.Printf("\n用户名‘\033[32m" + *username + "\033[0m’ 密码‘\033[32m" + password + "\033[0m’") From 0e98f7a40de3d966d966d1cce4545ab91c39dbff Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:39:39 +0800 Subject: [PATCH 02/12] =?UTF-8?q?linux=20mipsle=E4=BD=BF=E7=94=A8upx?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .goreleaser.yaml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2c6cccf..5839d80 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -54,24 +54,16 @@ upx: #压缩编译后的二进制文件大小 # ids: [build1, build2] # Filter by GOOS. - # - # Since: v1.19 - goos: [windows] + goos: [linux] # Filter by GOARCH. - # - # Since: v1.19 - goarch: [amd64] + goarch: [mipsle] # Filter by GOARM. - # - # Since: v1.19 # goarm: [8] # Filter by GOAMD64. - # - # Since: v1.19 - goamd64: [v1] + # goamd64: [v1] # Compress argument. # Valid options are from '1' (faster) to '9' (better), and 'best'. From 8cf84e820922bacb2ff740c62a8b40286f3432d2 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:18:17 +0800 Subject: [PATCH 03/12] go -version --- .goreleaser.yaml | 11 +++++++++++ appinfo/appinfo.go | 35 +++++++++++++++++++++++++++++++++++ webdemo.go | 7 ++++++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 appinfo/appinfo.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 5839d80..651919d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,6 +19,17 @@ builds: - main: ./webdemo.go env: - CGO_ENABLED=0 + ldflags: + - -s -w -X webdemo/appinfo.BuiltBy=goreleaser + - -X webdemo/appinfo.Tag={{ .Tag }} + - -X webdemo/appinfo.Date={{ .Date }} + - -X webdemo/appinfo.Commit={{ .FullCommit }} + # - -X main.Arch={{ .Arch }} + # - -X main.Os={{ .Os }} + #{{.名称模板}} https://goreleaser.com/customization/templates/#common-fields + + # gcflags: + # - all=-N -l goos: - linux - windows diff --git a/appinfo/appinfo.go b/appinfo/appinfo.go new file mode 100644 index 0000000..0f44393 --- /dev/null +++ b/appinfo/appinfo.go @@ -0,0 +1,35 @@ +package webdemo + +import ( + "fmt" + "runtime" +) + +var ( + BuiltBy string + Tag string + Commit string + Date string +) + +type Info struct { + AppName string + AppVersion string + BuildTime string + GitHash string + // Pid int + Platform string + GoVersion string +} + +var ( + AppInfo = Info{ + AppName: "简易文件服务器", + AppVersion: Tag, + BuildTime: Date, + GitHash: Commit, + // Pid: os.Getpid(), + Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), + GoVersion: runtime.Version(), + } +) diff --git a/webdemo.go b/webdemo.go index c529acc..d9746fb 100644 --- a/webdemo.go +++ b/webdemo.go @@ -9,6 +9,7 @@ import ( "net/http" "os" "strconv" + webdemo "webdemo/appinfo" "github.com/quic-go/quic-go" "github.com/quic-go/quic-go/http3" @@ -145,8 +146,12 @@ func main() { flag.StringVar(&password, "p", "", "密码") //短参数-p port := flag.Int("port", 443, "端口") var path_show = flag.String("path", ".", "文件路径") //文件加载路径,绝对路径可以,相对路径也可以,但需要注意加引号 + var showVersion bool + flag.BoolVar(&showVersion, "version", false, "-version输出版本信息") flag.Parse() - + if showVersion { + fmt.Println(webdemo.AppInfo) + } // result1 := exit_path(*crtPath) //crt证书是否存在 // result2 := exit_path(*keyPath) //key密钥是否存在 if exit_path(*path_show) != 0 { From 6acee9242b001d580e741f2672d201757c498766 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:19:08 +0800 Subject: [PATCH 04/12] =?UTF-8?q?github-actions=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8F=91=E5=B8=83release=EF=BC=8C=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=9D=A1=E4=BB=B6git=20tag=3Dv*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/goreleaser-actions.yml | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/goreleaser-actions.yml b/.github/workflows/goreleaser-actions.yml index 4dd55b7..6a8d24f 100644 --- a/.github/workflows/goreleaser-actions.yml +++ b/.github/workflows/goreleaser-actions.yml @@ -4,11 +4,13 @@ name: goreleaser-actions on: pull_request: push: + tags: + - "v*" branches: - dev -permissions: - contents: read #write +# permissions: +# contents: read #write jobs: goreleaser-actions: @@ -19,9 +21,18 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + + - run: | + echo "GIT_TAG=`echo $(git describe --tags --always)`" >> $GITHUB_ENV + echo "GIT_COMMIT_HASH=`echo $(git rev-parse HEAD)`" >> $GITHUB_ENV + - name: Set up Go uses: actions/setup-go@v4 + with: + go-version: '>=1.21.6' + - run: go version + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 @@ -32,6 +43,18 @@ jobs: args: release --snapshot --clean #--snapshot是不正式版本,取消git tag校验 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Github Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + # prerelease: ${{ contains(env.GIT_TAG, 'rc') }} + # files: './dist/*' + files: | + ./dist/*.tar.gz + ./dist/*.zip + ./dist/simple_file_download_server[\w\.\-\_]+_checksums.txt + - name: Upload assets uses: actions/upload-artifact@v4 From a7bf0357b5599e2175fc5a97475e8f52e5afdffa Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:22:28 +0800 Subject: [PATCH 05/12] fix goreleaser-actions.yml --- .github/workflows/goreleaser-actions.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/goreleaser-actions.yml b/.github/workflows/goreleaser-actions.yml index 6a8d24f..db1c88d 100644 --- a/.github/workflows/goreleaser-actions.yml +++ b/.github/workflows/goreleaser-actions.yml @@ -22,10 +22,6 @@ jobs: with: fetch-depth: 0 - - run: | - echo "GIT_TAG=`echo $(git describe --tags --always)`" >> $GITHUB_ENV - echo "GIT_COMMIT_HASH=`echo $(git rev-parse HEAD)`" >> $GITHUB_ENV - - name: Set up Go uses: actions/setup-go@v4 From dfcb23d17a81c9793148a23174542c0b730f4637 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:39:32 +0800 Subject: [PATCH 06/12] =?UTF-8?q?update=20-version=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webdemo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webdemo.go b/webdemo.go index d9746fb..04273c9 100644 --- a/webdemo.go +++ b/webdemo.go @@ -149,15 +149,19 @@ func main() { var showVersion bool flag.BoolVar(&showVersion, "version", false, "-version输出版本信息") flag.Parse() + if showVersion { - fmt.Println(webdemo.AppInfo) + fmt.Printf("%+v", webdemo.AppInfo) + os.Exit(0) } + // result1 := exit_path(*crtPath) //crt证书是否存在 // result2 := exit_path(*keyPath) //key密钥是否存在 if exit_path(*path_show) != 0 { log.Println("\033[31m ", *path_show, "\033[0m当前文件(文件夹)路径不存在,请重新输入") os.Exit(1) } + fileServer := http.FileServer(http.Dir(*path_show)) authHandler := basicAuth(fileServer, *username, password, *path_show) From 0507114604f4788e45c5d2faa97de9c8ef8e93e7 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:51:16 +0800 Subject: [PATCH 07/12] =?UTF-8?q?softprops/action-gh-release@v2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0env:GITHUB=5FTOKEN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/goreleaser-actions.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/goreleaser-actions.yml b/.github/workflows/goreleaser-actions.yml index db1c88d..4052989 100644 --- a/.github/workflows/goreleaser-actions.yml +++ b/.github/workflows/goreleaser-actions.yml @@ -2,12 +2,12 @@ name: goreleaser-actions #https://github.com/goreleaser/goreleaser-action #https://goreleaser.com/customization/builds/ 文档 on: - pull_request: + # pull_request: push: tags: - "v*" - branches: - - dev + branches: + - dev # permissions: # contents: read #write @@ -42,14 +42,16 @@ jobs: - name: Github Release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') #git push origin本地分支 release远程分支 v5.0版本号 with: # prerelease: ${{ contains(env.GIT_TAG, 'rc') }} - # files: './dist/*' - files: | - ./dist/*.tar.gz - ./dist/*.zip - ./dist/simple_file_download_server[\w\.\-\_]+_checksums.txt + files: './dist/*' + # files: | + # ./dist/*.tar.gz + # ./dist/*.zip + # ./dist/simple_file_download_server[\w\.\-\_]+_checksums.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload assets From d084d532ec5a17316b56f16eef3a6dd04038d889 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:00:33 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix=20actions=E8=A7=A6=E5=8F=91=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/goreleaser-actions.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/goreleaser-actions.yml b/.github/workflows/goreleaser-actions.yml index 4052989..25d5305 100644 --- a/.github/workflows/goreleaser-actions.yml +++ b/.github/workflows/goreleaser-actions.yml @@ -2,12 +2,11 @@ name: goreleaser-actions #https://github.com/goreleaser/goreleaser-action #https://goreleaser.com/customization/builds/ 文档 on: - # pull_request: push: + branches: + - dev tags: - "v*" - branches: - - dev # permissions: # contents: read #write From 475170df5d0c966ab81d7991ba15a792488a5735 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:28:19 +0800 Subject: [PATCH 09/12] =?UTF-8?q?update=20=E4=B8=8A=E4=BC=A0github=20relea?= =?UTF-8?q?se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/goreleaser-actions.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/goreleaser-actions.yml b/.github/workflows/goreleaser-actions.yml index 25d5305..4634eb1 100644 --- a/.github/workflows/goreleaser-actions.yml +++ b/.github/workflows/goreleaser-actions.yml @@ -44,11 +44,11 @@ jobs: if: startsWith(github.ref, 'refs/tags/') #git push origin本地分支 release远程分支 v5.0版本号 with: # prerelease: ${{ contains(env.GIT_TAG, 'rc') }} - files: './dist/*' - # files: | - # ./dist/*.tar.gz - # ./dist/*.zip - # ./dist/simple_file_download_server[\w\.\-\_]+_checksums.txt + # files: './dist/*' + files: | + ./dist/* + ./dist/simple_file_download_server[\w\.\-\_]+_checksums.txt + !./dist/[\w]+\.[json|yaml]+ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a1a524dd65f48d8652512be22a153b686d9d0fa8 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:13:53 +0800 Subject: [PATCH 10/12] add go.mod --- go.mod | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/go.mod b/go.mod index 86a0d82..67720df 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,20 @@ module webdemo go 1.21.6 + +require github.com/quic-go/quic-go v0.46.0 + +require ( + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect + github.com/onsi/ginkgo/v2 v2.9.5 // indirect + github.com/quic-go/qpack v0.4.0 // indirect + go.uber.org/mock v0.4.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect + golang.org/x/tools v0.21.0 // indirect +) From 1b55b793d558c888d501ea8441d38fadd5790262 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:01:54 +0800 Subject: [PATCH 11/12] Update .goreleaser.yaml --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 651919d..c868e2a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -26,7 +26,7 @@ builds: - -X webdemo/appinfo.Commit={{ .FullCommit }} # - -X main.Arch={{ .Arch }} # - -X main.Os={{ .Os }} - #{{.名称模板}} https://goreleaser.com/customization/templates/#common-fields + # {{.名称模板}} https://goreleaser.com/customization/templates/#common-fields # gcflags: # - all=-N -l From e89cd35aca26c2093689c0f5d3c5cef7ac4793a0 Mon Sep 17 00:00:00 2001 From: WLaoDuo <69497874+WLaoDuo@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:32:48 +0800 Subject: [PATCH 12/12] Revert "Merge branch 'master' into dev" This reverts commit 7915b3753050ca0439d01b9565f4a2b663fbff5e, reversing changes made to 1b55b793d558c888d501ea8441d38fadd5790262. --- go.mod | 3 ++- go.sum | 38 -------------------------------------- webdemo.go | 5 ++--- 3 files changed, 4 insertions(+), 42 deletions(-) delete mode 100644 go.sum diff --git a/go.mod b/go.mod index 98dc95c..67720df 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,13 @@ module webdemo go 1.21.6 +require github.com/quic-go/quic-go v0.46.0 + require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect github.com/onsi/ginkgo/v2 v2.9.5 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/quic-go v0.46.0 // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/crypto v0.23.0 // indirect golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect diff --git a/go.sum b/go.sum deleted file mode 100644 index 1625d72..0000000 --- a/go.sum +++ /dev/null @@ -1,38 +0,0 @@ -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.46.0 h1:uuwLClEEyk1DNvchH8uCByQVjo3yKL9opKulExNDs7Y= -github.com/quic-go/quic-go v0.46.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= -golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/webdemo.go b/webdemo.go index 0698858..04273c9 100644 --- a/webdemo.go +++ b/webdemo.go @@ -148,8 +148,7 @@ func main() { var path_show = flag.String("path", ".", "文件路径") //文件加载路径,绝对路径可以,相对路径也可以,但需要注意加引号 var showVersion bool flag.BoolVar(&showVersion, "version", false, "-version输出版本信息") - - flag.Parse() + flag.Parse() if showVersion { fmt.Printf("%+v", webdemo.AppInfo) @@ -162,7 +161,7 @@ func main() { log.Println("\033[31m ", *path_show, "\033[0m当前文件(文件夹)路径不存在,请重新输入") os.Exit(1) } - + fileServer := http.FileServer(http.Dir(*path_show)) authHandler := basicAuth(fileServer, *username, password, *path_show)