Documentation ¶
Overview ¶
Package common useful functionality for encoding and decoding objects
Index ¶
Constants ¶
const ( // Default number of pages DefaultPerPage = 20 // Default page number DefaultPage = 1 )
Variables ¶
This section is empty.
Functions ¶
func Contains ¶ added in v0.7.0
func Contains[T comparable](collection []T, element T) bool
Contains returns true if an element is present in a collection. Deprecated: use `slice.Contains` which import from `golang.org/x/exp/slices` instead
func FromJSONBase64 ¶
FromJSONBase64 decode encodeStr using base64, and then use json to convert to obj. Deprecated: use encoding.Base64Decode instead
func Paginate ¶
Paginate 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 ¶
ToJSONBase64 convert obj to json string, and then encode it with base64. Deprecated: use encoding.Base64Encode instead
Types ¶
This section is empty.