https://github.com/changsongl/isodd
isodd is package to check whether a number or string is odd. It is written in Golang. Same as is-odd in js.
https://github.com/changsongl/isodd
golang is-odd is-odd-or-even
Last synced: 2 months ago
JSON representation
isodd is package to check whether a number or string is odd. It is written in Golang. Same as is-odd in js.
- Host: GitHub
- URL: https://github.com/changsongl/isodd
- Owner: changsongl
- License: mit
- Created: 2020-12-25T10:17:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-26T11:10:36.000Z (over 4 years ago)
- Last Synced: 2024-12-18T08:39:36.699Z (5 months ago)
- Topics: golang, is-odd, is-odd-or-even
- Language: Go
- Homepage:
- Size: 3.31 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isodd
### Introduction:
isodd is for checking whether a integer, float or string is odd.
It is similar with the is-odd package which is written in javascript.
The package is 100% test coverage.### How to use it:
````shell script
# download package with go mod
go get github.com/changsongl/isodd# import package in your program
import "github.com/changsongl/isodd"
````````go
// some examplesvar strNum1 string = "1"
isOdd, err := isodd.String(strNum1) // true, nil
var strNum2 string = "0"
isOdd, err := isodd.String(strNum2) // false, nilvar num int64 = -1
isOdd := isodd.Int64(num) // true
var num int64 = 0
isOdd := isodd.Int64(num) // false// float type: it convert float to int type and
// then check whether it is odd
var num float32 = -1.32
isOdd := isodd.Float32(num) // true
var num float32 = 0
isOdd := isodd.Int64(num) // falsevar num interface = "0"
isOdd := isodd.Interface(num) // false
````### Code Coverage:
````shell script
go test -c -covermode=count -coverpkg ./..../isodd.test
PASS
coverage: 100.0% of statements in ./...
````