# README
go-helper
Under development
Package croonix/go-helper
help in the development of Go applications by providing some useful functions.
Usage
To use, only import as helper
and use it:
package main
import (
"fmt"
helper "github.com/croonix/go-helper"
)
...
Tasks
- Add Test files
# Functions
No description provided by the author
BadRequest is a simple function that returns a bad request message in JSON format with a BadRequest status code for Gin.
CatMode is a function that will print the request information It will print the URL, Method, Headers and Body of the request It is used to debug the request information.
CheckBody is a function that will print the request information It will print the URL, Method, Headers and Body of the request It is used to debug the request information Needs to be used with io.TeeReader to be able to read the body multiple times Example: - http.HandleFunc("/", CheckBody)
Output: - Request information: - Request URL: /?test=1 - Request Method: GET - Request Headers: map[Accept:[*/*] Accept-Encoding:[gzip] User-Agent:[Go-http-client/1.1]] - Request Body: test=1.
No description provided by the author
ConvertToBoolPointer is a simple function that converts a interface to a *bool.
No description provided by the author
No description provided by the author
GormDatabase is a function that returns a GORM database connection - Use simple Structure to connect to the database - Use the following environment variables: - DATABASE_USER - DATABASE_PASS - DATABASE_IP
Works only with MySQL databases (for now).
No description provided by the author
No description provided by the author
List2String converts a list of strings to a string in the format ["value1","value2"].
No description provided by the author
No description provided by the author
MustGetenv validates if the environment variable is set and returns it otherwise it will log a fatal error and exit the program It is used to validate the environment variables Example: - os.Setenv("TEST", "test") - log.Println(MustGetenv("TEST")) - log.Println(MustGetenv("TEST2"))
Output: - test - 2021/08/31 11:30:00 Missing environment variable: TEST2 - exit status 1.
No description provided by the author
ResponseMessage is a simple function that returns a message in JSON format with a status code for Gin.
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
# Structs
No description provided by the author
TimestampSerializer is a custom serializer for GORM to handle timestamps values.