init
continuous-integration/drone/push Build is passing Details

master v1.0.0
李光春 2 years ago
commit 3fcf1178fe

@ -0,0 +1,11 @@
kind: pipeline
type: docker
name: clone
steps:
- name: test-golang
image: golang:1.18
commands:
- go env -w GO111MODULE=on
- go env -w GOPROXY=https://goproxy.cn,direct
- go test -v ./...

8
.gitignore vendored

@ -0,0 +1,8 @@
.env
.git
.svn
.idea
.vscode
*.log
gomod.sh
/vendor/

@ -0,0 +1,25 @@
<h1>
<a href="https://www.dtapp.net/">Golang Verify</a>
</h1>
📦 验证
[comment]: <> (go)
[![godoc](https://pkg.go.dev/badge/go.dtapp.net/goverify?status.svg)](https://pkg.go.dev/go.dtapp.net/goverify)
[![goproxy.cn](https://goproxy.cn/stats/go.dtapp.net/goverify/badges/download-count.svg)](https://goproxy.cn/stats/go.dtapp.net/goverify)
[![goreportcard.com](https://goreportcard.com/badge/go.dtapp.net/goverify )](https://goreportcard.com/report/go.dtapp.net/goverify)
[![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/go.dtapp.net/goverify)
#### 安装使用
```go
go get -v -u go.dtapp.net/goverify
```
#### 导入
```go
import (
"go.dtapp.net/goverify"
)
```

@ -0,0 +1,3 @@
module go.dtapp.net/goverify
go 1.18

@ -0,0 +1,30 @@
package goverify
import (
"regexp"
)
// Mobile 验证手机号码
// 移动134 135 136 137 138 139 147 150 151 152 157 158 159 178 182 183 184 187 188 198
// 联通130 131 132 145 155 156 166 171 175 176 185 186
// 电信133 149 153 173 177 180 181 189 199
// 虚拟运营商: 170 195
func Mobile(mobile string) bool {
regular := "^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,5,8-9]))[0-9]{8}$"
reg := regexp.MustCompile(regular)
return reg.MatchString(mobile)
}
// IdCard 验证身份证号码
func IdCard(idCard string) bool {
regular := "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$"
reg := regexp.MustCompile(regular)
return reg.MatchString(idCard)
}
// Email 验证邮箱号码
func Email(email string) bool {
pattern := `^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z]\.){1,4}[a-z]{2,4}$`
reg := regexp.MustCompile(pattern)
return reg.MatchString(email)
}

@ -0,0 +1,9 @@
package goverify
import "testing"
func TestMobile(t *testing.T) {
t.Log(Mobile("13800138000"))
t.Log(Mobile("33800138000"))
t.Log(Mobile("1380013800"))
}

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