From c1d3231768aeb923763fffe0a2dd82d3ddec0343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Wed, 3 Aug 2022 17:47:06 +0800 Subject: [PATCH] - update --- LICENSE | 21 +++++++++++++++++++++ README.md | 17 +++++++++++++++++ goarray.go | 13 +++++++++++++ version.go | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ff84bbf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 李光春 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cdf4275 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +

+Golang Array +

+ +📦 Golang Array + +[comment]: <> (go) +[![godoc](https://pkg.go.dev/badge/go.dtapp.net/goarray?status.svg)](https://pkg.go.dev/go.dtapp.net/goarray) +[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/goarray/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/goarray) +[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/goarray)](https://goreportcard.com/report/go.dtapp.net/goarray) +[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net%2Fgoarray) + +#### 安装 + +```go +go get -v -u go.dtapp.net/goarray +``` diff --git a/goarray.go b/goarray.go index c31bcdd..46ababd 100644 --- a/goarray.go +++ b/goarray.go @@ -16,3 +16,16 @@ func TurnString(ss []string) (s string) { } return s } + +// RemoveDuplicateElement 去重 +func RemoveDuplicateElement[T string | int | int16 | int32](ss []T) []T { + result := make([]T, 0, len(ss)) + temp := map[T]struct{}{} + for _, item := range ss { + if _, ok := temp[item]; !ok { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +} diff --git a/version.go b/version.go index ef4c95b..181e0a9 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package goarray -const Version = "1.0.0" +const Version = "1.0.1"