commit 1ad48c6266a843d859e044a45051b3e16424ed49 Author: 李光春 Date: Tue May 24 22:47:12 2022 +0800 - init diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1c25ff1 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,12 @@ +kind: pipeline +type: docker +name: clone + +steps: + - name: Test + image: golang:1.18 + commands: + - go env -w GO111MODULE=on + - go env -w GOPROXY=https://goproxy.cn,direct + - go test -v ./... + - go test -bench=. -benchmem \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..442794a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.env +.git +.svn +.idea +.vscode +*.log +gomod.sh +/vendor/ \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..810214b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module go.dtapp.net/goarray + +go 1.18 diff --git a/goarray.go b/goarray.go new file mode 100644 index 0000000..c31bcdd --- /dev/null +++ b/goarray.go @@ -0,0 +1,18 @@ +package goarray + +func Grouping() { + +} + +// TurnString []string 转 string +func TurnString(ss []string) (s string) { + sl := len(ss) + for k, v := range ss { + if k+1 == sl { + s = s + v + } else { + s = s + v + "," + } + } + return s +} diff --git a/goarray_test.go b/goarray_test.go new file mode 100644 index 0000000..cb648d5 --- /dev/null +++ b/goarray_test.go @@ -0,0 +1,13 @@ +package goarray + +import "testing" + +func TestTurnString(t *testing.T) { + t.Log(TurnString([]string{"111", "222", "333"})) +} + +func BenchmarkTurnString(b *testing.B) { + for i := 0; i < b.N; i++ { + b.Log(TurnString([]string{"111", "222", "333"})) + } +} diff --git a/version.go b/version.go new file mode 100644 index 0000000..ef4c95b --- /dev/null +++ b/version.go @@ -0,0 +1,3 @@ +package goarray + +const Version = "1.0.0" diff --git a/version_test.go b/version_test.go new file mode 100644 index 0000000..97b8dd6 --- /dev/null +++ b/version_test.go @@ -0,0 +1,7 @@ +package goarray + +import "testing" + +func TestVersion(t *testing.T) { + t.Log(Version) +}