diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..384d3547 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: go + +go: + - 1.17.x + - tip + +before_install: + - go get -t -v ./... + +script: + - go test -race -coverprofile=coverage.txt -covermode=atomic + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/README.md b/README.md index 6872ab6b..ee80561a 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,16 @@ 📦 Golang 扩展包 [comment]: <> (go) +[![Release](https://img.shields.io/github/release/dtapps/go-library.svg)](https://github.com/dtapps/go-library/releases/latest) [![go](https://github.com/dtapps/go-library/actions/workflows/go.yml/badge.svg)](https://github.com/dtapps/go-library/actions/workflows/go.yml) [![godoc](https://pkg.go.dev/badge/github.com/dtapps/go-library?status.svg)](https://pkg.go.dev/github.com/dtapps/go-library) [![goproxy.cn](https://goproxy.cn/stats/github.com/dtapps/go-library/badges/download-count.svg)](https://goproxy.cn/stats/github.com/dtapps/go-library) [![goreportcard.com](https://goreportcard.com/badge/github.com/dtapps/go-library)](https://goreportcard.com/report/github.com/dtapps/go-library) [![deps.dev](https://img.shields.io/badge/deps-go-red.svg)](https://deps.dev/go/github.com%2Fdtapps%2Fgo-library) [![Coverage Status](https://coveralls.io/repos/github/dtapps/go-library/badge.svg?branch=master)](https://coveralls.io/github/dtapps/go-library?branch=master) - - +[![Sourcegraph](https://sourcegraph.com/github.com/dtapps/go-library/-/badge.svg)](https://sourcegraph.com/github.com/dtapps/go-library?badge) +[![Build status](https://ci.appveyor.com/api/projects/status/d6rq6xynt8wkev5k?svg=true)](https://ci.appveyor.com/project/dtapps/go-library) +[![codecov](https://codecov.io/gh/dtapps/go-library/branch/master/graph/badge.svg?token=BrtbyKKPQX)](https://codecov.io/gh/dtapps/go-library) #### 安装使用 diff --git a/utils/gofloat/gofloat.go b/utils/gofloat/gofloat.go new file mode 100644 index 00000000..1d7585a0 --- /dev/null +++ b/utils/gofloat/gofloat.go @@ -0,0 +1,13 @@ +package float + +import "math" + +// ToInt64 将float64转成精确的int64 +func ToInt64(num float64, retain int) int64 { + return int64(num * math.Pow10(retain)) +} + +// ToFloat64 精准float64 +func ToFloat64(num float64, retain int) float64 { + return num * math.Pow10(retain) +}