helper

package
v0.0.0-...-b820d78 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Copyright (c) 2021, Refactory.id All rights reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashAndSalt

func HashAndSalt(pwd []byte) string

func LenKeys

func LenKeys(ctx context.Context, c *redis.Client, key string) (int, bool)

Return Length and Boolean from given keys arguments

ex: key => "user1" || "*" || "user*"
@param c *redis.Client
@param key string

func ParseIdn

func ParseIdn(date string) int64

input date 2006-01-02

func ParseTime

func ParseTime(locationName string, value string) time.Time

func SetField

func SetField(obj interface{}, name string, value interface{}) error

func TimeIn

func TimeIn(name string) time.Time

Types

type EmptyObj

type EmptyObj struct{}

*

  • EmptyObj is used when data doesn't want to be null on json

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

NullTime for nil time.Time

func (NullTime) MarshalJSON

func (n NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*NullTime) UnmarshalJSON

func (n *NullTime) UnmarshalJSON(b []byte) error

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Response

type Response struct {
	Status  bool        `json:"status"`
	Message string      `json:"message"`
	Errors  interface{} `json:"errors"`
	Data    interface{} `json:"data"`
	Embed   interface{} `json:"embed"`
}

*

  • Response is used for static shape json return

func BuildErrorResponse

func BuildErrorResponse(message string, errs string, data interface{}) Response

*

  • Create new Response and returns Errors's data
  • @param status boolean
  • @param message string
  • @param data interface{}

func BuildResponse

func BuildResponse(status bool, message string, data interface{}) Response

*

  • Create new Response and returns Response's data
  • @param status boolean
  • @param message string
  • @param data interface{}

func BuildResponseEmbed

func BuildResponseEmbed(status bool, message string, data interface{}, embed interface{}) Response

*

  • Create new Response and returns Response's data
  • @param status boolean
  • @param message string
  • @param data interface{}
  • @param embed interface{}

Jump to

Keyboard shortcuts

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