From 4b45d06929a3403864476dc22be08fdc0debd2c9 Mon Sep 17 00:00:00 2001 From: goloop Date: Tue, 6 Jun 2023 19:41:18 +0300 Subject: [PATCH] Change License --- .gitignore | 4 ++- .godocdown.md | 49 ------------------------------- LICENSE | 41 ++++++++++++-------------- Makefile | 59 ------------------------------------- README.md | 78 +++++++++++++++++-------------------------------- doc.go | 7 ----- doc_test.go | 22 -------------- go.mod | 4 +-- go.sum | 6 ++-- methods_test.go | 4 +-- slug_test.go | 4 +-- tools.go | 2 +- tools_test.go | 2 +- 13 files changed, 60 insertions(+), 222 deletions(-) delete mode 100644 .godocdown.md delete mode 100644 Makefile delete mode 100644 doc_test.go diff --git a/.gitignore b/.gitignore index f6fe045..29fb41b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ # Dependency directories # vendor/ .vscode/ -cmd/ \ No newline at end of file +cmd/ + +coverage.out \ No newline at end of file diff --git a/.godocdown.md b/.godocdown.md deleted file mode 100644 index 7cb89ff..0000000 --- a/.godocdown.md +++ /dev/null @@ -1,49 +0,0 @@ -[//]: # (!!!Don't modify the README.md, use `make readme` to generate it!!!) - - -[![Go Report Card](https://goreportcard.com/badge/github.com/goloop/slug)](https://goreportcard.com/report/github.com/goloop/slug) [![License](https://img.shields.io/badge/license-BSD-blue)](https://github.com/goloop/slug/blob/master/LICENSE) [![License](https://img.shields.io/badge/godoc-YES-green)](https://godoc.org/github.com/goloop/slug) - -*Version: .ModuleVersion* - -# slug - -{{.EmitSynopsis}} - - -## Installation - -To install this module use `go get` as: - - $ go get -u github.com/goloop/slug - -## Quick Start - -To use this module import it as: `github.com/goloop/slug` - -### Conversion functions - -#### Fast conversion. - -Use the `Make` method to convert a string to slug. - -```go -package main - -import ( - "fmt" - - "github.com/goloop/slug" -) - -func main() { - // Simple generate slug from the string. - s := slug.Make("Hello 世界") - h := "https://example.com/" - fmt.Printf("%s%s\n", h, s) - - // Output: - // https://example.com/Hello-Shi-Jie -} -``` - -{{ .EmitUsage }} diff --git a/LICENSE b/LICENSE index 1949033..84852ae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,24 +1,21 @@ -Copyright (c) 2022, GoLoop. -All rights reserved. +MIT License -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. Neither the name of the GoLoop nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. +Copyright (c) 2020 GoLoop -THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER AND CONTRIBUTORS ''AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER AND CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +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/Makefile b/Makefile deleted file mode 100644 index 7ba0c0c..0000000 --- a/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# GOLOOP -# -# Load data about the package: -# NAME -# Name of the GoLang's module; -# VERSION -# Current version. -# REPOSITORY -# The name of the repository where the package is stored, -# for example: github.com/goloop; -MODULE_NAME:=$(shell cat go.mod | grep module | awk '{split($$2,v,"/"); print v[3]}') -MODULE_VERSION:=$(shell cat doc.go | grep "const version" | awk '{gsub(/"/, "", $$4); print $$4}') -MODULE_MAJOR_VERSION:=$(shell cat doc.go | grep "const version" | awk '{gsub(/"/, "", $$4); print $$4}' | awk '{split($$0,r,"."); print r[1]}') -REPOSITORY_NAME:=$(shell cat go.mod | grep module | awk '{split($$2,v,"/"); print v[1] "/" v[2]}') - -# Help information. -define MSG_HELP -Go-package's manager of -${MODULE_NAME} v${MODULE_VERSION} - -Commands: - help - Show this help information - test - Run tests - cover - Check test coverage - readme - Create readme from the GoLang code - - Requires `godocdown`, install as: - go get github.com/robertkrimen/godocdown/godocdown - tag - Create git-tag with current version of package -endef - -# Constants. -export MSG_HELP -REPOSITORY_PATH=${REPOSITORY_NAME}/${MODULE_NAME} - -all: help -help: - @echo "$$MSG_HELP" -test: - @go clean -testcache; \ - go test ${REPOSITORY_PATH} -cover: - @go test -cover ${REPOSITORY_PATH} && \ - go test -coverprofile=/tmp/coverage.out ${REPOSITORY_PATH} && \ - go tool cover -func=/tmp/coverage.out && \ - go tool cover -html=/tmp/coverage.out -readme: -ifeq (, $(shell which godocdown)) - @go get github.com/robertkrimen/godocdown/godocdown -endif - @godocdown -plain=true -template=.godocdown.md ./ | \ - sed -e 's/\.ModuleVersion/v${MODULE_VERSION}/g' > README.md -tag: - @bash -c 'read -p "Do you want to create v${MODULE_VERSION} tag [y/n]?: " yn; case $${yn} in "y") git tag "v${MODULE_VERSION}"; exit 0;; *) exit 0;; esac' diff --git a/README.md b/README.md index df487ab..b38b781 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ -[//]: # (!!!Don't modify the README.md, use `make readme` to generate it!!!) +[![Go Report Card](https://goreportcard.com/badge/github.com/goloop/slug)](https://goreportcard.com/report/github.com/goloop/slug) [![License](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/goloop/slug/blob/master/LICENSE) [![License](https://img.shields.io/badge/godoc-YES-green)](https://godoc.org/github.com/goloop/slug) -[![Go Report Card](https://goreportcard.com/badge/github.com/goloop/slug)](https://goreportcard.com/report/github.com/goloop/slug) [![License](https://img.shields.io/badge/license-BSD-blue)](https://github.com/goloop/slug/blob/master/LICENSE) [![License](https://img.shields.io/badge/godoc-YES-green)](https://godoc.org/github.com/goloop/slug) - -*Version: v0.0.2* - # slug Package slug generate slug from Unicode string, URL-friendly slugify with @@ -15,7 +11,9 @@ multiple languages support. To install this module use `go get` as: - $ go get -u github.com/goloop/slug +``` +$ go get -u github.com/goloop/slug +``` ## Quick Start @@ -40,73 +38,49 @@ func main() { // Simple generate slug from the string. s := slug.Make("Hello 世界") h := "https://example.com/" - fmt.Printf("%s%s\n", h, s) - // Output: - // https://example.com/Hello-Shi-Jie + fmt.Printf("%s%s\n", h, s) + // Output: https://example.com/Hello-Shi-Jie } ``` -## Usage - -#### func Lower - - func Lower(t string) string - -Lower returns slug in lowercase. - -#### func Make - - func Make(t string) string - -Make returns slug from string. - -#### func Upper - - func Upper(t string) string - -Upper returns slug in uppercase. - -#### func Version - - func Version() string +## Functions -Version returns the version of the module. +- **Lower**(t string) string -#### type Slug + Lower returns slug in lowercase. - type Slug struct { - } +- **Make**(t string) string + Make returns slug from string. -Slug is the slug constructor. +- **Upper**(t string) string -#### func New + Upper returns slug in uppercase. - func New() *Slug +- **Version**() string -New retursn pointer to Slug. + Version returns the version of the module. -#### func (*Slug) Lang +- **New*() *Slug - func (s *Slug) Lang(l string) *Slug + New returns pointer to Slug. -Lang sets the type of language features to use during slugify. -#### func (*Slug) Lower +## Methods of Slug - func (s *Slug) Lower(t string) string +- **Lang**(l string) *Slug -Lower returns slug in lowercase. + Lang sets the type of language features to use during slugify. -#### func (*Slug) Make +- **Lower**(t string) string - func (s *Slug) Make(t string) string + Lower returns slug in lowercase. -Make returns slug from string. +- **Make**(t string) string -#### func (*Slug) Upper + Make returns slug from string. - func (s *Slug) Upper(t string) string +- **Upper**(t string) string -Upper returns slug in uppercase. + Upper returns slug in uppercase. diff --git a/doc.go b/doc.go index 0691ff5..585a7d2 100644 --- a/doc.go +++ b/doc.go @@ -1,10 +1,3 @@ // Package slug generate slug from Unicode string, // URL-friendly slugify with multiple languages support. package slug - -const version = "0.0.2" - -// Version returns the version of the module. -func Version() string { - return "v" + version -} diff --git a/doc_test.go b/doc_test.go deleted file mode 100644 index 06b7d16..0000000 --- a/doc_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package slug - -import ( - "strings" - "testing" -) - -// TestVersion tests the package version. -// Note: each time you change the major version, you need to fix the tests. -func TestVersion(t *testing.T) { - var expected = "v0." // change it for major version - - version := Version() - if strings.HasPrefix(version, expected) != true { - t.Error("incorrect version") - } - - if len(strings.Split(version, ".")) != 3 { - t.Error("version format should be as " + - "v{major_version}.{minor_version}.{patch_version}") - } -} diff --git a/go.mod b/go.mod index 8ca0cd5..0dcf031 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/goloop/slug -go 1.17 +go 1.20 -require github.com/goloop/t13n v1.2.1 +require github.com/goloop/t13n v1.4.0 diff --git a/go.sum b/go.sum index b18073c..abedb88 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ -github.com/goloop/t13n v1.2.1 h1:ArpoIEGoUCmvHvNvL+R1YdtkmWJrNjWEI7mUpwLjXho= -github.com/goloop/t13n v1.2.1/go.mod h1:1A8l9eGVc905TSEVbUS36ctQSEFtW7n5FBOc1Tp32r8= +github.com/goloop/t13n v1.3.2 h1:enhFPS4rZvp77ai6cbJg2zvsxFC0ZVlT34xsUPdmW7g= +github.com/goloop/t13n v1.3.2/go.mod h1:JCd2qLplmTZHTFq9K8PoW7UVghN1KCTFS8qMBh0nhfY= +github.com/goloop/t13n v1.4.0 h1:HFlP1sExMzaoZBgchycHaHxeVt61Qfp3t4dt7E3pYc8= +github.com/goloop/t13n v1.4.0/go.mod h1:JCd2qLplmTZHTFq9K8PoW7UVghN1KCTFS8qMBh0nhfY= diff --git a/methods_test.go b/methods_test.go index 7e1de20..4890985 100644 --- a/methods_test.go +++ b/methods_test.go @@ -6,7 +6,7 @@ import ( // TestMake tests Make function. func TestMake(t *testing.T) { - var tests = []struct { + tests := []struct { value string expected string }{ @@ -30,7 +30,7 @@ func TestMake(t *testing.T) { // TestLower tests Lower function. func TestLower(t *testing.T) { - var tests = []struct { + tests := []struct { value string lowerExpected string upperExpected string diff --git a/slug_test.go b/slug_test.go index d0bafb6..9b765f7 100644 --- a/slug_test.go +++ b/slug_test.go @@ -8,7 +8,7 @@ import ( // TestObjMake tests Make method. func TestObjMake(t *testing.T) { - var tests = []struct { + tests := []struct { value string expected string }{ @@ -34,7 +34,7 @@ func TestObjMake(t *testing.T) { // TestObjLower tests Lower method. func TestObjLower(t *testing.T) { - var tests = []struct { + tests := []struct { value string lowerExpected string upperExpected string diff --git a/tools.go b/tools.go index e87ef3f..e2d37fa 100644 --- a/tools.go +++ b/tools.go @@ -11,7 +11,7 @@ import ( func slugRules(ts lang.TransState) (string, int, bool) { // Ignore ranges. // Important: edit maps ascending order only! - var ignored = [][]int{ + ignored := [][]int{ {0, 47}, {58, 64}, {91, 96}, diff --git a/tools_test.go b/tools_test.go index e1c0d3c..fa20290 100644 --- a/tools_test.go +++ b/tools_test.go @@ -8,7 +8,7 @@ import ( // TestSlugRules tests slugRules function. func TestSlugRules(t *testing.T) { - var tests = []struct { + tests := []struct { item lang.TransState value string seek int