From 58e88df33fa9d1223d5d005f44af6c5e384b1209 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Oct 2023 02:24:03 +0000 Subject: [PATCH 1/7] Bump github.com/essentialkaos/ek/v12 from 12.79.0 to 12.80.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.79.0 to 12.80.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.79.0...v12.80.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 26e610f..ea47cfa 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.79.0 + github.com/essentialkaos/ek/v12 v12.80.0 github.com/essentialkaos/npck v1.6.1 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect github.com/klauspost/compress v1.17.0 // indirect - golang.org/x/crypto v0.13.0 // indirect - golang.org/x/sys v0.12.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/sys v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 8b2f60c..be71195 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.79.0 h1:Dq/bCqk8/N5h/r5jJA2UHc1YoUEVYcc7xnR0DI5L9wA= -github.com/essentialkaos/ek/v12 v12.79.0/go.mod h1:S9/XSKhEAdylL3PF8GAnUeKKyd92VrDGR4YGacHfz0c= +github.com/essentialkaos/ek/v12 v12.80.0 h1:Yy3VF9J18qdhMZt1Tl7fKtjLvg6PdZX5rcDdk92KNys= +github.com/essentialkaos/ek/v12 v12.80.0/go.mod h1:X0gkyjBCP4QiD+sV4D52aquLDLGUmHteMEL7Rsgbev0= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg= @@ -12,7 +12,7 @@ github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From a47f983fb695de9ec4d0c3bd8e1d36aedd1700de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 02:21:18 +0000 Subject: [PATCH 2/7] Bump github.com/essentialkaos/ek/v12 from 12.80.0 to 12.82.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.80.0 to 12.82.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.80.0...v12.82.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ea47cfa..026d057 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.80.0 + github.com/essentialkaos/ek/v12 v12.82.0 github.com/essentialkaos/npck v1.6.1 ) diff --git a/go.sum b/go.sum index be71195..9654879 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.80.0 h1:Yy3VF9J18qdhMZt1Tl7fKtjLvg6PdZX5rcDdk92KNys= -github.com/essentialkaos/ek/v12 v12.80.0/go.mod h1:X0gkyjBCP4QiD+sV4D52aquLDLGUmHteMEL7Rsgbev0= +github.com/essentialkaos/ek/v12 v12.82.0 h1:8JqG7E1RWhMJq2CuSV0oaR96pmEjngLPG3cnJ++EJeQ= +github.com/essentialkaos/ek/v12 v12.82.0/go.mod h1:X0gkyjBCP4QiD+sV4D52aquLDLGUmHteMEL7Rsgbev0= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg= From 91fe0cd7672aefc4c36d6629aba539ecb5a5b80b Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 17 Oct 2023 18:20:23 +0300 Subject: [PATCH 3/7] [gen] Improve alias and eol info handling --- common/rbinstall.spec | 10 ++++--- gen/gen.go | 61 ++++++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/common/rbinstall.spec b/common/rbinstall.spec index 33f3311..d8babe7 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -10,7 +10,7 @@ Summary: Utility for installing prebuilt Ruby to rbenv Name: rbinstall -Version: 3.1.1 +Version: 3.1.2 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -38,7 +38,7 @@ Utility for installing different prebuilt versions of Ruby to rbenv. %package gen Summary: Utility for generating RBInstall index -Version: 3.0.4 +Version: 3.1.0 Release: 0%{?dist} Group: Development/Tools @@ -50,7 +50,7 @@ Utility for generating RBInstall index. %package clone Summary: Utility for cloning RBInstall repository -Version: 3.0.4 +Version: 3.0.5 Release: 0%{?dist} Group: Development/Tools @@ -118,6 +118,10 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Tue Oct 17 2023 Anton Novojilov - 3.1.2-0 +- [gen] Improved alias and eol info handling +- Dependencies update + * Tue Oct 03 2023 Anton Novojilov - 3.1.1-0 - [gen] Fixed bug with searching base version - Dependencies update diff --git a/gen/gen.go b/gen/gen.go index a6bf208..f4df2b5 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -40,7 +40,7 @@ import ( // App info const ( APP = "RBInstall Gen" - VER = "3.0.4" + VER = "3.1.0" DESC = "Utility for generating RBInstall index" ) @@ -80,10 +80,7 @@ type fileInfoSlice []FileInfo func (s fileInfoSlice) Len() int { return len(s) } func (s fileInfoSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s fileInfoSlice) Less(i, j int) bool { - return sortutil.VersionCompare( - fmtVersionName(s[i].File), - fmtVersionName(s[j].File), - ) + return sortutil.VersionCompare(fmtVersionName(s[i].File), fmtVersionName(s[j].File)) } // ////////////////////////////////////////////////////////////////////////////////// // @@ -93,8 +90,8 @@ var aliasInfo map[string]string var optMap = options.Map{ OPT_OUTPUT: {Value: INDEX_NAME}, - OPT_EOL: {}, - OPT_ALIAS: {}, + OPT_EOL: {Value: "eol.json"}, + OPT_ALIAS: {Value: "alias.json"}, OPT_NO_COLOR: {Type: options.BOOL}, OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, OPT_VER: {Type: options.BOOL, Alias: "ver"}, @@ -190,18 +187,20 @@ func configureUI() { } } -// loadEOLInfo load EOL info from file +// loadEOLInfo loads EOL info from file func loadEOLInfo() { eolInfo = make(map[string]bool) - if !options.Has(OPT_EOL) { - return + if !fsutil.CheckPerms("FRS", options.GetS(OPT_EOL)) { + if !options.Has(OPT_EOL) { + return + } } err := jsonutil.Read(options.GetS(OPT_EOL), &eolInfo) if err != nil { - printErrorAndExit(err.Error()) + printErrorAndExit("Can't read EOL data: %v", err) } } @@ -209,14 +208,16 @@ func loadEOLInfo() { func loadAliasInfo() { aliasInfo = make(map[string]string) - if !options.Has(OPT_ALIAS) { - return + if !fsutil.CheckPerms("FRS", options.GetS(OPT_ALIAS)) { + if !options.Has(OPT_ALIAS) { + return + } } err := jsonutil.Read(options.GetS(OPT_ALIAS), &aliasInfo) if err != nil { - printErrorAndExit(err.Error()) + printErrorAndExit("Can't read alias data: %v", err) } } @@ -330,6 +331,10 @@ func buildIndex(dataDir string) { } printIndexStats(newIndex) + printExtraInfo() + + fmtutil.Separator(false) + saveIndex(outputFile, newIndex) fmtc.Printf( @@ -415,8 +420,28 @@ func printIndexStats(i *index.Index) { fmtutil.PrettyNum(i.Meta.Items), fmtutil.PrettySize(i.Meta.Size, " "), ) +} - fmtutil.Separator(false) +// printExtraInfo prints info about used alias/eol data +func printExtraInfo() { + fmtutil.Separator(false, "EXTRA") + + eolModTime, _ := fsutil.GetMTime(options.GetS(OPT_EOL)) + aliasModTime, _ := fsutil.GetMTime(options.GetS(OPT_ALIAS)) + + fmtc.If(len(eolInfo) == 0).Println(" {*}EOL: {!} {s}—{!}") + fmtc.If(len(eolInfo) != 0).Printf( + " {*}EOL: {!} %s {s-}(%s){!}\n", + options.GetS(OPT_EOL), + timeutil.Format(eolModTime, "%Y/%m/%d %H:%M"), + ) + + fmtc.If(len(aliasInfo) == 0).Println(" {*}Alias:{!} {s}—{!}") + fmtc.If(len(aliasInfo) != 0).Printf( + " {*}Alias:{!} %s {s-}(%s){!}\n", + options.GetS(OPT_ALIAS), + timeutil.Format(aliasModTime, "%Y/%m/%d %H:%M"), + ) } // saveIndex saves index data as JSON to file @@ -435,7 +460,7 @@ func saveIndex(outputFile string, i *index.Index) { err = os.WriteFile(outputFile, indexData, 0644) if err != nil { - printErrorAndExit(err.Error()) + printErrorAndExit("Can't save index: %v", err) } os.Chmod(outputFile, 0644) @@ -558,8 +583,8 @@ func genUsage() *usage.Info { info.AppNameColorTag = "{*}" + colorTagApp info.AddOption(OPT_OUTPUT, "Custom index output {s-}(default: index.json){!}", "file") - info.AddOption(OPT_EOL, "File with EOL information", "file") - info.AddOption(OPT_ALIAS, "File with aliases information", "file") + info.AddOption(OPT_EOL, "File with EOL information {s-}(default: eol.json){!}", "file") + info.AddOption(OPT_ALIAS, "File with aliases information {s-}(default: alias.json){!}", "file") info.AddOption(OPT_NO_COLOR, "Disable colors in output") info.AddOption(OPT_HELP, "Show this help message") info.AddOption(OPT_VER, "Show version") From 62bfc6c823fa5a081864a1a5aa4f6fcf645be451 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 17 Oct 2023 18:22:37 +0300 Subject: [PATCH 4/7] Improve verbose version info --- support/support_linux.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/support/support_linux.go b/support/support_linux.go index 08ec75d..7ac8b7a 100644 --- a/support/support_linux.go +++ b/support/support_linux.go @@ -15,6 +15,7 @@ import ( "github.com/essentialkaos/ek/v12/fmtutil" "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/system" + "github.com/essentialkaos/ek/v12/system/container" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -26,13 +27,14 @@ func showOSInfo() { if err == nil { fmtutil.Separator(false, "OS INFO") - printInfo(12, "Name", osInfo.Name) - printInfo(12, "Pretty Name", osInfo.PrettyName) - printInfo(12, "Version", osInfo.VersionID) + printInfo(12, "Name", osInfo.ColoredName()) + printInfo(12, "Pretty Name", osInfo.ColoredPrettyName()) + printInfo(12, "Version", osInfo.Version) printInfo(12, "ID", osInfo.ID) printInfo(12, "ID Like", osInfo.IDLike) printInfo(12, "Version ID", osInfo.VersionID) printInfo(12, "Version Code", osInfo.VersionCodename) + printInfo(12, "Platform ID", osInfo.PlatformID) printInfo(12, "CPE", osInfo.CPEName) } @@ -52,11 +54,13 @@ func showOSInfo() { containerEngine := "No" - switch { - case fsutil.IsExist("/.dockerenv"): + switch container.GetEngine() { + case container.DOCKER: containerEngine = "Yes (Docker)" - case fsutil.IsExist("/run/.containerenv"): + case container.PODMAN: containerEngine = "Yes (Podman)" + case container.LXC: + containerEngine = "Yes (LXC)" } fmtc.NewLine() From 100b76c69fb21917afad7e6b84263bf1a56be4bb Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 17 Oct 2023 23:08:04 +0300 Subject: [PATCH 5/7] Update spec --- common/rbinstall.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/common/rbinstall.spec b/common/rbinstall.spec index d8babe7..b5096e7 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -120,6 +120,7 @@ rm -rf %{buildroot} %changelog * Tue Oct 17 2023 Anton Novojilov - 3.1.2-0 - [gen] Improved alias and eol info handling +- [cli|gen|clone] Improve verbose version info - Dependencies update * Tue Oct 03 2023 Anton Novojilov - 3.1.1-0 From 4379c3eee4343cda5ea3956404633a28d01ff565 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 17 Oct 2023 23:16:51 +0300 Subject: [PATCH 6/7] Dependencies update --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 026d057..556bc10 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - github.com/klauspost/compress v1.17.0 // indirect + github.com/klauspost/compress v1.17.1 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/sys v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 9654879..705dc58 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrY github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg= github.com/essentialkaos/npck v1.6.1/go.mod h1:Leny9a2R4otIGqZdnrs8swhI9KvwO+Rmmn2zThpPoN4= -github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2gPS5g= +github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= From f661e8ef487a2b8724c9e31af6670eb0520fc40e Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 18 Oct 2023 00:33:09 +0300 Subject: [PATCH 7/7] Code refactoring --- cli/cli.go | 10 +++++----- clone/clone.go | 6 +++--- common/rbinstall.spec | 1 + gen/gen.go | 8 ++++---- index/index.go | 6 +++--- support/support.go | 2 +- support/support_linux.go | 8 +++----- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 0a992d9..993bf29 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -1498,7 +1498,7 @@ func getVersionFromFile() (string, error) { return "", fmtc.Errorf("Can't read version file: %v", err) } - versionName := strings.Trim(string(versionData[:]), " \n\r") + versionName := strings.Trim(string(versionData), " \n\r") if versionName == "" { return "", fmtc.Errorf("Can't use version file - file malformed") @@ -1731,7 +1731,7 @@ func isVersionSupportedByBundler(rubyVersion string) bool { // getNameWithoutPatchLevel return name without -p0 func getNameWithoutPatchLevel(name string) string { - return strings.Replace(name, "-p0", "", -1) + return strings.ReplaceAll(name, "-p0", "") } // parseGemInfo extract name and version of gem @@ -1800,11 +1800,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "rbinstall")) + fmt.Print(bash.Generate(info, "rbinstall")) case "fish": - fmt.Printf(fish.Generate(info, "rbinstall")) + fmt.Print(fish.Generate(info, "rbinstall")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "rbinstall")) + fmt.Print(zsh.Generate(info, optMap, "rbinstall")) default: return 1 } diff --git a/clone/clone.go b/clone/clone.go index 8ce8e83..eddf655 100644 --- a/clone/clone.go +++ b/clone/clone.go @@ -500,11 +500,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "rbinstall-clone")) + fmt.Print(bash.Generate(info, "rbinstall-clone")) case "fish": - fmt.Printf(fish.Generate(info, "rbinstall-clone")) + fmt.Print(fish.Generate(info, "rbinstall-clone")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "rbinstall-clone")) + fmt.Print(zsh.Generate(info, optMap, "rbinstall-clone")) default: return 1 } diff --git a/common/rbinstall.spec b/common/rbinstall.spec index b5096e7..748577b 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -121,6 +121,7 @@ rm -rf %{buildroot} * Tue Oct 17 2023 Anton Novojilov - 3.1.2-0 - [gen] Improved alias and eol info handling - [cli|gen|clone] Improve verbose version info +- [cli|gen|clone] Code refactoring - Dependencies update * Tue Oct 03 2023 Anton Novojilov - 3.1.1-0 diff --git a/gen/gen.go b/gen/gen.go index f4df2b5..5d4ee5a 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -269,7 +269,7 @@ func buildIndex(dataDir string) { alreadyExist := false filePath := path.Join(dataDir, fileInfo.OS, fileInfo.Arch, fileInfo.File) - fileName := strings.Replace(fileInfo.File, ".tzst", "", -1) + fileName := strutil.Exclude(fileInfo.File, ".tzst") fileSize := fsutil.GetSize(filePath) fileAdded, _ := fsutil.GetCTime(filePath) @@ -554,11 +554,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "rbinstall-clone")) + fmt.Print(bash.Generate(info, "rbinstall-clone")) case "fish": - fmt.Printf(fish.Generate(info, "rbinstall-clone")) + fmt.Print(fish.Generate(info, "rbinstall-clone")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "rbinstall-clone")) + fmt.Print(zsh.Generate(info, optMap, "rbinstall-clone")) default: return 1 } diff --git a/index/index.go b/index/index.go index 7daf05f..effd966 100644 --- a/index/index.go +++ b/index/index.go @@ -75,8 +75,8 @@ type versionInfoSlice []*VersionInfo func (s versionInfoSlice) Len() int { return len(s) } func (s versionInfoSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s versionInfoSlice) Less(i, j int) bool { - iv := strings.Replace(s[i].Name, "-", ".", -1) - jv := strings.Replace(s[j].Name, "-", ".", -1) + iv := strings.ReplaceAll(s[i].Name, "-", ".") + jv := strings.ReplaceAll(s[j].Name, "-", ".") return sortutil.VersionCompare(iv, jv) } @@ -86,7 +86,7 @@ func (s versionInfoSlice) Less(i, j int) bool { // NewIndex return pointer to new index struct func NewIndex() *Index { return &Index{ - UUID: uuid.GenUUID(), + UUID: uuid.UUID4().String(), Meta: &Metadata{}, Data: make(map[string]DistData), } diff --git a/support/support.go b/support/support.go index 9374af0..7ebfd40 100644 --- a/support/support.go +++ b/support/support.go @@ -118,7 +118,7 @@ func getHashColorBullet(v string) string { // printInfo formats and prints info record func printInfo(size int, name, value string) { - name = name + ":" + name += ":" size++ if value == "" { diff --git a/support/support_linux.go b/support/support_linux.go index 7ac8b7a..9068a93 100644 --- a/support/support_linux.go +++ b/support/support_linux.go @@ -42,11 +42,9 @@ func showOSInfo() { if err != nil { return - } else { - if osInfo == nil { - fmtutil.Separator(false, "SYSTEM INFO") - printInfo(12, "Name", systemInfo.OS) - } + } else if osInfo == nil { + fmtutil.Separator(false, "SYSTEM INFO") + printInfo(12, "Name", systemInfo.OS) } printInfo(12, "Arch", systemInfo.Arch)