diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..081b737 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 数据源本地存储已忽略文件 +/dataSources/ +/dataSources.local.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6bde8be --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/zyos_go_pay.iml b/.idea/zyos_go_pay.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/zyos_go_pay.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..da0dc62 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git + +go 1.16 diff --git a/stringutil/reverse.go b/stringutil/reverse.go new file mode 100644 index 0000000..92ad007 --- /dev/null +++ b/stringutil/reverse.go @@ -0,0 +1,10 @@ +package stringutil + +// Reverse returns its argument string reversed rune-wise left to right. +func Reverse(s string) string { + r := []rune(s) + for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { + r[i], r[j] = r[j], r[i] + } + return string(r) +} \ No newline at end of file diff --git a/stringutil/reverse_test.go b/stringutil/reverse_test.go new file mode 100644 index 0000000..31da3fc --- /dev/null +++ b/stringutil/reverse_test.go @@ -0,0 +1,18 @@ +package stringutil + +import "testing" + +func TestReverse(t *testing.T) { + for _, c := range []struct { + in, want string + }{ + {"Hello, world", "dlrow ,olleH"}, + {"Hello, 世界", "界世 ,olleH"}, + {"", ""}, + } { + got := Reverse(c.in) + if got != c.want { + t.Errorf("Reverse(%q) == %q, want %q", c.in, got, c.want) + } + } +} \ No newline at end of file