master
李光春 2 years ago
parent 472ab6b16f
commit 65064c3b2b

@ -1,42 +0,0 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build:
working_directory: ~/repo
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: circleci/golang:1.18
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go mod download
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: |
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
- store_test_results:
path: /tmp/test-reports
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
# Inside the workflow, you define the jobs you want to run.
jobs:
- build

@ -3,9 +3,15 @@ type: docker
name: clone
steps:
- name: test-golang
- 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 -v ./...
- name: Benchmark
image: golang:1.18
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go test -bench=. -benchmem

@ -1,38 +0,0 @@
name: coverage
on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master ]
paths-ignore:
- '**.md'
jobs:
test:
name: Test with Coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Check out code
uses: actions/checkout@v2
- name: Install dependencies
run: |
go mod download
- name: Run Unit tests
run: |
go test -race -covermode atomic -coverprofile=covprofile ./...
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=covprofile -service=github

@ -1,27 +0,0 @@
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Test
run: go test -v ./...
- name: Test
run: go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- name: Coverage
run: bash <(curl -s https://codecov.io/bash)

2
.gitignore vendored

@ -4,4 +4,4 @@
.idea
.vscode
*.log
gitmod.sh
gomod.sh

@ -1,7 +0,0 @@
language: go
go:
- master
script:
- go test -v ./...

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 茂名聚合科技有限公司
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

@ -2,24 +2,16 @@
<a href="https://www.dtapp.net/">Golang String</a>
</h1>
📦 Golang 字符串组件
📦 Golang 字符串
[comment]: <> (go)
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/gostring?status.svg)](https://pkg.go.dev/go.dtapp.net/gostring)
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/gostring/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/gostring)
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/gostring)](https://goreportcard.com/report/go.dtapp.net/gostring)
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net/gostring)
[![godoc](https://pkg.go.dev/badge/github.com/dtapps/gostring?status.svg)](https://pkg.go.dev/github.com/dtapps/gostring)
[![goproxy.cn](https://goproxy.cn/stats/github.com/dtapps/gostring/badges/download-count.svg)](https://goproxy.cn/stats/github.com/dtapps/gostring)
[![goreportcard.com](https://goreportcard.com/badge/github.com/dtapps/gostring)](https://goreportcard.com/report/github.com/dtapps/gostring)
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/github.com%2Fdtapps%2Fgostring)
#### 安装使用
#### 安装
```go
go get -v -u go.dtapp.net/gostring
go get -v -u github.com/dtapps/gostring
```
#### 导入
```go
import (
"go.dtapp.net/gostring"
)
```

@ -1,3 +1,3 @@
module go.dtapp.net/gostring
module github.com/dtapps/gostring
go 1.18

@ -1,3 +0,0 @@
go get -u && go mod tidy
go get -u all
go mod vendor

@ -10,8 +10,6 @@ import (
"unicode/utf8"
)
const Version = "1.0.3"
// ToString 转换成string
func ToString(value interface{}) string {
if value == nil {
@ -96,12 +94,15 @@ func TrimLastChar(s string) string {
// Split 字符串分隔
func Split(s string, sep string) []string {
if len(s) <= 0 {
return []string{}
}
return strings.Split(s, sep)
}
// Contains 判断字符串是否包含某个字符
func Contains(s, substr string) bool {
return strings.Contains(s, substr)
func Contains(s, sep string) bool {
return strings.Contains(s, sep)
}
func NumericalToString(value interface{}) (string, bool) {

@ -2,6 +2,7 @@ package gostring
import (
"fmt"
"log"
"strings"
"testing"
)
@ -34,9 +35,32 @@ func TestString(t *testing.T) {
func TestSplit(t *testing.T) {
t.Log(Split("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20", ","))
t.Log(Split(",10,", ","))
t.Log(len(Split(",10,", ",")))
t.Log(Split(",10,", ",")[1 : len(Split(",1,", ","))-1])
t.Log(len(Split(",10,", ",")[1 : len(Split(",1,", ","))-1]))
t.Log(Contains("", ","))
t.Log(len([]string{}))
t.Log(Split("/pages/preferential_recharge/goods_details?goods_id=G02022062517457120", "="))
}
func TestContains(t *testing.T) {
t.Log(Contains("1", ","))
t.Log(Contains("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20", ","))
}
func TestToFloat64(t *testing.T) {
t.Log(ToFloat64("120"))
t.Log(ToFloat64("120.9"))
t.Log(ToFloat64("100.100.100"))
if "100.100.100" > "111.111.111" {
log.Println("1")
} else {
log.Println("2")
}
}
func TestReplace(t *testing.T) {
t.Log(Replace("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20", ",", "|"))
t.Log(Replace("/v1/a/{agent_user_id}/d/g", "{agent_user_id}", "A102DFB78FADE96F1E"))
}

@ -0,0 +1,3 @@
package gostring
const Version = "1.0.4"
Loading…
Cancel
Save