Skip to content

Commit f500d81

Browse files
authored
Merge pull request #108 from kcmvp/path
#107: code refactor for embed.FS
2 parents 1d5a217 + 213c5d5 commit f500d81

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/gbc/command/root.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/spf13/cobra"
1515
"github.com/tidwall/gjson"
1616
"os" //nolint
17+
"path"
1718
"path/filepath"
1819
"strings" //nolint
1920
"sync" //nolint
@@ -35,7 +36,7 @@ var (
3536

3637
func usageTemplate() string {
3738
once.Do(func() {
38-
bytes, _ := templates.ReadFile(fmt.Sprintf("%s/usage.tmpl", tmplDir))
39+
bytes, _ := templates.ReadFile(path.Join(tmplDir, "usage.tmpl"))
3940
usage = color.YellowString(string(bytes))
4041
})
4142
return usage
@@ -48,7 +49,8 @@ func parseArtifacts(cmd *cobra.Command, args []string, name string) (gjson.Resul
4849
if test, uqf := utils.TestCaller(); test {
4950
data, err = os.ReadFile(filepath.Join(artifact.CurProject().Root(), "target", uqf, "config.json"))
5051
} else {
51-
data, err = resources.ReadFile(fmt.Sprintf("%s/config.json", resourceDir))
52+
path.Join()
53+
data, err = resources.ReadFile(path.Join(resourceDir, "config.json"))
5254
}
5355
if err != nil {
5456
return result, err
@@ -73,7 +75,7 @@ func installPlugins(cmd *cobra.Command, args []string) error {
7375
}
7476
if len(plugin.Config) > 0 {
7577
if _, err = os.Stat(filepath.Join(artifact.CurProject().Root(), plugin.Config)); err != nil {
76-
if data, err = resources.ReadFile(fmt.Sprintf("%s/%s", resourceDir, plugin.Config)); err == nil {
78+
if data, err = resources.ReadFile(path.Join(resourceDir, plugin.Config)); err == nil {
7779
if err = os.WriteFile(filepath.Join(artifact.CurProject().Root(), plugin.Config), data, os.ModePerm); err != nil {
7880
break
7981
}

0 commit comments

Comments
 (0)