Categorygithub.com/erajayatech/go-helper
modulepackage
1.4.6
Repository: https://github.com/erajayatech/go-helper.git
Documentation: pkg.go.dev

# README

go-helper

helper for go app

Installation

go get github.com/erajayatech/go-helper

Usage

ValidateStruct

import "github.com/erajayatech/go-helper"

// struct
type Request struct {
	Email  string `json:"email" example:"[email protected]" validate:"required" msg:"error_invalid_email"`
	Name string `json:"name" example:"andrie" validate:"required" msg:"error_invalid_name"`
}

var RequestErrorMessage = map[string]string{
	"error_invalid_email":  "email is required",
	"error_invalid_name":  "name is required",
}

func main() {
    var (
        request Request
    )

    errorMessage := helper.ValidateStruct(request, RequestErrorMessage)

    a, _ := json.MarshalIndent(errorMessage, "", "\t")
	fmt.Print(string(a))
}
{
	"email": "email is required",
	"name": "name is required"
}

FormatRupiah

import "github.com/erajayatech/go-helper"

func main() {
	amountRupiah := helper.FormatRupiah(3000)

	fmt.Println(amountRupiah)
}
"Rp 3.000"

FormatGender

import "github.com/erajayatech/go-helper"

func main() {
	gender := helper.FormatGender(1)

	fmt.Println(gender)
}
"M"

MustGetEnv

import "github.com/erajayatech/go-helper"

func main() {
	env := helper.MustGetEnv("MODE")

	fmt.Println(env)
}
"local"

FormatInfoText

import "github.com/erajayatech/go-helper"

func main() {
	env := helper.FormatInfoText("update data","11000034","processing","system")

	fmt.Println(env)
}
"update data #11000034 processing - updated_by: system"

ExpectedInt

import "github.com/erajayatech/go-helper"

func main() {
	value := helper.ExpectedInt(6.5)

	fmt.Println(value)
}
6

ExpectedInt64

import "github.com/erajayatech/go-helper"

func main() {
	var amount int64 = 67

	value := helper.ExpectedInt64(amount)

	fmt.Println(value)
}
67

ExpectedString

import "github.com/erajayatech/go-helper"

func main() {
	value := helper.ExpectedString(67)

	fmt.Println(value)
}
"67"

FloatToString

import "github.com/erajayatech/go-helper"

func main() {
	value := helper.FloatToString(0.06)

	fmt.Println(value)
}
"0.060000"

ValidateDateFormat

import "github.com/erajayatech/go-helper"

func main() {
	date, err := helper.ValidateDateFormat("01-09-2010")

	fmt.Println(date)
}
"01-09-2010"

ConvertIsoDateFormat

import "github.com/erajayatech/go-helper"

func main() {
	date, err := helper.ConvertIsoDateFormat("2022/07/10")

	fmt.Println(date)
}
"10-07-2022"

SanitizeSpecialChar

import "github.com/erajayatech/go-helper"

func main() {
	data, err := helper.SanitizeSpecialChar("jalan\nnamajalan\n")

	fmt.Println(data)
}
"jalan namajalan"

ContainsSliceString

import "github.com/erajayatech/go-helper"

func main() {
	array := []string{"abc", "def"}
	data, err := helper.ContainsSliceString(array,"def")

	fmt.Println(data)
}
true

CreateKeyValuePairs

import "github.com/erajayatech/go-helper"

func main() {
	array := map[string]string{
				"name":  "name is required",
				"email": "email is required",
			}
	data, err := helper.CreateKeyValuePairs(array)

	fmt.Println(data)
}
name="name is required"
email="email is required"

### IsSourceJdsport
```go
import "github.com/erajayatech/go-helper"

func main() {
	value := helper.IsSourceJdsport("jdsport")

	fmt.Println(value)
}
true

### IsSourcePaymentLink
```go
import "github.com/erajayatech/go-helper"

func main() {
	value := helper.IsSourcePaymentLink("telemarketing")

	fmt.Println(value)
}
true

License

MIT

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author