Skip to content

Commit

Permalink
fix Str_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzhijian committed Jul 25, 2019
1 parent 01a38db commit 39051ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion php.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func Str_replace(search, replace, subject string, count ...int) string {
return strings.Replace(subject, search, replace, count[0])
}

return strings.ReplaceAll(subject, search, replace)
return strings.Replace(subject, search, replace, -1)
}

func Strtoupper(str string) string {
Expand Down
12 changes: 6 additions & 6 deletions php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestMb_strlen(t *testing.T) {
}

func TestStr_replace(t *testing.T) {
t.Log(Str_replace("hello", "HELLO", "hello world hello!", 1))
t.Log(Str_replace("hello", "HELLO", "hello world hello!"))
t.Log(Str_replace("hello", "111", "hello world hello!", 1))
t.Log(Str_replace("hello", "111", "hello world hello!"))
}

func TestStrtolower(t *testing.T) {
Expand Down Expand Up @@ -177,11 +177,11 @@ func TestFile_exists(t *testing.T) {
}

func TestIs_file(t *testing.T) {
t.Error(Is_file("php.go"))
t.Error(Is_file("/Users/wuzhijian"))
t.Log(Is_file("php.go"))
t.Log(Is_file("/Users/wuzhijian"))
}

func TestIs_dir(t *testing.T) {
t.Error(Is_dir("php.go"))
t.Error(Is_dir("/Users/wuzhijian"))
t.Log(Is_dir("php.go"))
t.Log(Is_dir("/Users/wuzhijian"))
}

0 comments on commit 39051ef

Please sign in to comment.