gopackage

package module
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 15 Imported by: 0

README

MrAndreID / Go Package

Go Reference

The MrAndreID/GoPackage is a collection of functions for package in Go Language.

Table of Contents

Installation

To use The MrAndreID/GoPackage, you must follow the steps below:

  • Get Dependancies
go get -u github.com/MrAndreID/gopackage

Usage

To use The MrAndreID/GoPackage, you must ensure that you meet the following requirements:

Custom Validator
import (
    "github.com/MrAndreID/gopackage"
	"github.com/labstack/echo/v4"
)

e := echo.New()
e.Validator = gopackage.CustomValidator()
Custom HTTP Error for Echo Framework
import (
    "github.com/MrAndreID/gopackage"
	"github.com/labstack/echo/v4"
)

e := echo.New()
e.HTTPErrorHandler = gopackage.EchoCustomHTTPErrorHandler
Custom JSON
import (
    "github.com/MrAndreID/gopackage"
	"github.com/labstack/echo/v4"
)

e := echo.New()
e.JSONSerializer = gopackage.CustomJSONSerializer()
GoRM Data Table
import (
    "github.com/MrAndreID/gopackage"
)

gopackage.DataTable(
    ctx,
    queryBuilder,
    []string{"name", "level"},
    "name",
    "asc",
    "id",
    "desc",
    page,
    &limit,
    request.Search,
    false,
)
Binding Request for Echo Framework
import (
    "github.com/MrAndreID/gopackage"
)

if err := gopackage.EchoBindValidateRequest(c, &req); err != nil {
    return err
}
SeaweedFS Client
import (
    "github.com/MrAndreID/gopackage"
)

seaweedFSData, err := gopackage.NewSeaweedFS("127.0.0.1", "9333", false)

if err != nil {
    return err
}

publicURL, err := seaweedFSData.Upload(base64File)

if err != nil {
    return err
}

base64File, err := seaweedFSData.Download(publicURL)

if err != nil {
    return err
}

err := seaweedFSData.Delete(publicURL)

if err != nil {
    return err
}

Versioning

I use Semantic Versioning. For the versions available, see the tags on this repository.

Authors

Andrea Adam - MrAndreID

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Official Documentation for Go Language

Documentation for Go Language can be found on the Go Package website.

License

The MrAndreID/GoPackage is released under the MIT License. See the LICENSE file for more information.

More

Documentation can be found on https://go.dev/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataTable

func DataTable(queryBuilder *gorm.DB, searchField []string, orderField string, sortField string, defaultOrder string, defaultSort string, page int, length *int, search string, filter bool) (filterStatus bool)

func EchoBindValidateRequest

func EchoBindValidateRequest(c *echo.Context, i request) error

func EchoCustomHTTPErrorHandler

func EchoCustomHTTPErrorHandler(c *echo.Context, err error)

func ParseValidationErrors added in v2.2.0

func ParseValidationErrors(err error) []validationError

Types

type CustomJSONData

type CustomJSONData struct{}

func CustomJSONSerializer

func CustomJSONSerializer() *CustomJSONData

func (*CustomJSONData) Deserialize

func (cjd *CustomJSONData) Deserialize(c *echo.Context, i any) error

func (*CustomJSONData) Serialize

func (cjd *CustomJSONData) Serialize(c *echo.Context, i any, indent string) error

type CustomValidatorData

type CustomValidatorData struct {
	// contains filtered or unexported fields
}

func CustomValidator

func CustomValidator() *CustomValidatorData

func (*CustomValidatorData) Validate

func (cvd *CustomValidatorData) Validate(i any) error

type EchoCustomHTTPErrorResponse

type EchoCustomHTTPErrorResponse struct {
	Status  bool   `json:"status"`
	Message string `json:"message"`
	Data    any    `json:"data"`
	Meta    any    `json:"meta"`
	Error   any    `json:"error"`
}

type SeaweedFSData

type SeaweedFSData struct {
	URL string
}

func NewSeaweedFS

func NewSeaweedFS(host string, port string, ssl bool) (*SeaweedFSData, error)

func (*SeaweedFSData) Delete

func (sfs *SeaweedFSData) Delete(publicURL string) error

func (*SeaweedFSData) Download

func (sfs *SeaweedFSData) Download(publicURL string) (string, error)

func (*SeaweedFSData) Upload

func (sfs *SeaweedFSData) Upload(base64File string) (string, error)

Jump to

Keyboard shortcuts

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