Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
chore: Rename file.Extension to file.AddExt
Browse files Browse the repository at this point in the history
  • Loading branch information
akimon658 committed Jul 23, 2022
1 parent a37fcd8 commit 42017e7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func remove(args []string, force bool) int {

code := 0
for _, v := range args {
v = file.Extension(v)
v = file.AddExt(v)

target := filepath.Join(gobin, v)
stat, err := os.Stat(target)
Expand Down
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func extractUserSpecifyPkg(pkgs []goutil.Package, targets []string) []goutil.Pac
}

for _, v := range targets {
v = file.Extension(v)
v = file.AddExt(v)
for _, w := range pkgs {
if v == w.Name {
result = append(result, w)
Expand Down
2 changes: 1 addition & 1 deletion file/extension.go → file/add_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

const extWin = ".exe"

func Extension(name string) string {
func AddExt(name string) string {
if runtime.GOOS == "windows" && !strings.HasSuffix(name, extWin) {
name += extWin
}
Expand Down
4 changes: 2 additions & 2 deletions file/extension_test.go → file/add_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/jaswdr/faker"
)

func TestExtension(t *testing.T) {
func TestAddExt(t *testing.T) {
fileName := faker.New().Lorem().Word()
fileNameWithExtension := fileName + extWin
testCases := []struct {
Expand All @@ -29,7 +29,7 @@ func TestExtension(t *testing.T) {

for _, v := range testCases {
t.Run(v.name, func(t *testing.T) {
result := Extension(v.input)
result := AddExt(v.input)
if runtime.GOOS == "windows" {
if result != v.expected {
t.Errorf("expected %s, got %s", v.expected, result)
Expand Down

0 comments on commit 42017e7

Please sign in to comment.