Giter Club home page Giter Club logo

lib-document's Introduction

sympathy-backend library

Image util

func ScaleImage(i image.Image, w, h int) (image.Image, error) 

Usage: To scale an image to specified width and height

Input param:

i: Image need to scale width and height

w: output width

h: output height


func EncodeImage(buf io.Writer, i image.Image, ext string) error

Usage: Write the image i to buf in jpeg, png or gif format

Input param:

buf: writer

i: image need to encode

ext: extension of input image


func GetImageByPath(path string) (draw.Image, string)

Usage: Get the image from specified path

Input param:

path: path of image need to get


func GetImageByPathWithRect(path string, rect image.Rectangle) (draw.Image, string)

Usage: Get the image from specified path and rectangle

Input param:

path: path of image need to get

rect: rectangle of image


Pagination

type (
	// Pager ...
	Pager struct {
		TotalCount  int64
		PerPage     int64
		CurrentPage int64
		PrevItem    PageItem
		NextItem    PageItem
		PageLinks   []PageItem
	}

	// PageItem ...
	PageItem struct {
		Page       int64
		Label      string
		Location   string
		IsDisabled bool
		IsCurrent  bool
	}
)

func CreatePager(ctx context.Context, count, perpage, current int64) (*Pager, error)

Usage: Create a pagination pager

Input param:

ctx: a context

count: total result

perpage: number result per page

current: current page


func getLocation(location string, page int64) string

Usage: Get location (url) of specified page

Input param:

location: current location

page: specified page need to get location


Param Ulti

func paramTo(kind reflect.Kind, param string) (interface{}, bool, error)

Usage: Convert params to a specified type

Input param:

kind: type need to convert to

param: a URL param


func ParamToInt64(param string) (int64, bool, error)

Usage: Convert params to type int64

Input param:

param: a URL param


func ParamToStr(param string) (string, bool, error)

Usage: Convert params to type string

Input param:

param: a URL param


Ultility

func Random(n int) string

Usage: Make a random string with n characters both uppercase and lowercase

Input param:

n: number of characters


func RandomLC(n int) string

Usage: Make a random string with n lowercase characters

Input param:

n: number of characters


func GetHash256(str string) string

Usage: Encrypt a string using SHA-256 algorithm

Input param:

str: string


func PasswordHash(pw string) (string, error)

Usage: Generate a hash password from password

Input param:

pw: password


func PasswordVerify(hash, pw string) error

Usage: Compare password with hash password to verify

Input param:

hash: hash password

pw: password

lib-document's People

Contributors

cuongpv0504 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.