imago

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 10 Imported by: 5

README

imago

a tool box with go

how to use

File

File.Read

package main

import (
	"fmt"
	"log"

	"github.com/tiantour/imago"
)

func main() {
	path := "you file path"
	body, err := imago.NewFile().Read(path)
	if err != nil {
		log.Println(err.Error())
	}
	fmt.Println(string(body))
}

File.Write

package main

import (
	"log"

	"github.com/tiantour/imago"
)

func main() {
	path := "your file path"
	data := "your file data"
	err := imago.NewFile().Write(path, []byte(data))
	if err != nil {
		log.Println(err.Error())
	}
}	

Random

Random.Number

package main

import (
	"fmt"

	"github.com/tiantour/imago"
)

func main() {
	number := imago.NewRandom().Number(9)
	fmt.Println(number)
}

Random.String

package main

import (
	"fmt"

	"github.com/tiantour/imago"
)

func main() {
	number := imago.NewRandom().Number(9)
	fmt.Println(number)
}

Random.ULID

package main

import (
	"fmt"

	"github.com/tiantour/imago"
)

func main() {
	str := imago.NewRandom().ULID()
	fmt.Println(str)
}

Text.IsDigit

package main

import (
	"fmt"

	"github.com/tiantour/imago"
)

func main() {
	text := "1234"
	result := imago.NewText().IsDigit(text)
	fmt.Println(result)
}

Text.IsHan

package main

import (
	"fmt"

	"github.com/tiantour/imago"
)

func main() {
	text := "汉字"
	result := imago.NewText().IsHan(text)
	fmt.Println(result)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct{}

File file

func NewFile

func NewFile() *File

NewFile new file

func (*File) Read

func (f *File) Read(path string) ([]byte, error)

Read file read date 2016-12-31 author andy.jiang

func (*File) Write

func (f *File) Write(path string, data []byte) error

Write file write

type Random

type Random struct{}

Random random

func NewRandom

func NewRandom() *Random

NewRandom new random

func (*Random) Number

func (rd *Random) Number(length int) int

Number random number

func (*Random) Text

func (rd *Random) Text(length int) string

Text random text

type Text

type Text struct{}

Text text

func NewText

func NewText() *Text

NewText new text

func (*Text) FilterEmoji

func (t *Text) FilterEmoji(str string) string

FilterEmoji filterEmoji

func (*Text) IsDigit

func (t *Text) IsDigit(str string) bool

IsDigit text is digit

func (*Text) IsHan

func (t *Text) IsHan(str string) bool

IsHan text is han

type Veriry added in v1.0.1

type Veriry struct{}

Veriry verify

func NewVerify added in v1.0.1

func NewVerify() *Veriry

NewVerify new verify

func (*Veriry) Card added in v1.0.1

func (v *Veriry) Card(s string) bool

Card verify card

func (*Veriry) Email added in v1.0.1

func (v *Veriry) Email(s string) bool

Email verify email

func (*Veriry) Phone added in v1.0.1

func (v *Veriry) Phone(s string) bool

Phone verify phone

func (*Veriry) Telephone added in v1.0.1

func (v *Veriry) Telephone(s string) bool

Telephone verify telephone

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL