Skip to content

Commit

Permalink
add version print
Browse files Browse the repository at this point in the history
  • Loading branch information
csznet committed Apr 7, 2024
1 parent 3c8ab99 commit 24958ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
Expand All @@ -22,7 +19,7 @@ jobs:

- name: Build Linux arm64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o goForward main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-X main.conf.Version=${GITHUB_REF/refs\/tags\//}" -o goForward main.go
- name: Zip Linux amd64
run: |
Expand All @@ -35,15 +32,15 @@ jobs:
- name: Build Linux amd64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o goForward main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.conf.Version=${GITHUB_REF/refs\/tags\//}" -o goForward main.go
- name: Zip Linux amd64
run: |
zip goForward.zip goForward
- name: Build Windows amd64
run: |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o goForward.exe main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-X main.conf.Version=${GITHUB_REF/refs\/tags\//}" -o goForward.exe main.go
- name: Zip Windows amd64
run: |
Expand Down
3 changes: 3 additions & 0 deletions conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ var WebPass string

// TCP超时
var TcpTimeout int

// 版本号
var Version string
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"sync"

"csz.net/goForward/conf"
Expand All @@ -11,6 +12,9 @@ import (
)

func main() {
if conf.Version != "" {
fmt.Println("goForward Version " + conf.Version)
}
go web.Run()
if conf.TcpTimeout < 5 {
conf.TcpTimeout = 5
Expand Down

0 comments on commit 24958ae

Please sign in to comment.