diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 49cc1df..673a763 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -9,9 +9,9 @@ builds: - -trimpath ldflags: - -s -w - - -X {{ .ModulePath }}/global.Version={{ .Version }} - - -X {{ .ModulePath }}/global.Commit={{ .ShortCommit }} - - -X {{ .ModulePath }}/global.CommitDate={{ .CommitDate }} + - -X {{ .ModulePath }}/pkg/consts.Version={{ .Version }} + - -X {{ .ModulePath }}/pkg/consts.Commit={{ .ShortCommit }} + - -X {{ .ModulePath }}/pkg/consts.CommitDate={{ .CommitDate }} mod_timestamp: '{{ .CommitTimestamp }}' goos: - linux diff --git a/cmd/version/version.go b/cmd/version/version.go index 52d3daf..5ffbc6f 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -4,7 +4,7 @@ import ( "bytes" _ "embed" "github.com/fatih/color" - "github.com/iyear/tdl/global" + "github.com/iyear/tdl/pkg/consts" "github.com/spf13/cobra" "runtime" "text/template" @@ -20,9 +20,9 @@ var Cmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { buf := &bytes.Buffer{} _ = template.Must(template.New("version").Parse(version)).Execute(buf, map[string]interface{}{ - "Version": global.Version, - "Commit": global.Commit, - "Date": global.CommitDate, + "Version": consts.Version, + "Commit": consts.Commit, + "Date": consts.CommitDate, "GoVersion": runtime.Version(), "GOOS": runtime.GOOS, "GOARCH": runtime.GOARCH, diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index 4930233..2442d6a 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -1,39 +1,8 @@ package consts import ( - "github.com/gotd/td/telegram" - "github.com/iyear/tdl/global" "os" "path/filepath" - "runtime" -) - -// TODO(iyear): usr -X flag to set id and hash -const ( - AppID = 17349 - AppHash = "344583e45741c457fe1862106095a5eb" -) - -const ( - DownloadModeURL = "url" -) - -var ( - Device = telegram.DeviceConfig{ - DeviceModel: "tdl", - SystemVersion: runtime.GOOS, - AppVersion: global.Version, - } -) - -var ( - DataDir string - KVPath string -) - -const ( - DocsPath = "docs" - DownloadPath = "downloads" ) func init() { diff --git a/pkg/consts/dl.go b/pkg/consts/dl.go new file mode 100644 index 0000000..0054e55 --- /dev/null +++ b/pkg/consts/dl.go @@ -0,0 +1,7 @@ +package consts + +const ( + DownloadModeURL = "url" +) + +const DownloadPath = "downloads" diff --git a/pkg/consts/path.go b/pkg/consts/path.go new file mode 100644 index 0000000..70c1630 --- /dev/null +++ b/pkg/consts/path.go @@ -0,0 +1,7 @@ +package consts + +var ( + DataDir string + KVPath string + DocsPath = "docs" +) diff --git a/pkg/consts/telegram.go b/pkg/consts/telegram.go new file mode 100644 index 0000000..b8f3acc --- /dev/null +++ b/pkg/consts/telegram.go @@ -0,0 +1,21 @@ +package consts + +import ( + "github.com/gotd/td/telegram" + "runtime" +) + +// TODO(iyear): usr -X flag to set id and hash +// Telegram desktop client +const ( + AppID = 17349 + AppHash = "344583e45741c457fe1862106095a5eb" +) + +var ( + Device = telegram.DeviceConfig{ + DeviceModel: "tdl", + SystemVersion: runtime.GOOS, + AppVersion: Version, + } +) diff --git a/global/global.go b/pkg/consts/version.go similarity index 88% rename from global/global.go rename to pkg/consts/version.go index 77c5dcb..11743a1 100644 --- a/global/global.go +++ b/pkg/consts/version.go @@ -1,4 +1,4 @@ -package global +package consts // vars below are set by '-X' flag var (