common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default number of pages
	DefaultPerPage = 20

	// Default page number
	DefaultPage = 1
)

Variables

This section is empty.

Functions

func FromJSONBase64

func FromJSONBase64(encodeStr string, obj interface{}) error

Decode encodeStr using base64, and then use json to convert to obj.

func Paginate

func Paginate(total, perPage, page int) (begin, end int)

This function implements the paging of List, inputting the total number of data (usually the length of Slice), the number of each page, and the page number. The function guarantees that Begin and End do not exceed the total number of data.

If input perPage is less than 1, it will be set as DefaultPerPage. If input page is less than 1, it will be set as DefaultPage.

Returns the start and end position of the pagination.

func ToJSONBase64

func ToJSONBase64(obj interface{}) (string, error)

Convert obj to json string, and then encode it with base64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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