gopackage

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 16 Imported by: 2

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.CustomJSON()
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.EchoBindRequest(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(ctx context.Context, queryBuilder *gorm.DB, searchField []string, orderField string, sortField string, defaultOrder string, defaultSort string, page int, length *int, search string, filter bool) (filterStatus bool)

func EchoBindRequest

func EchoBindRequest(c echo.Context, i request) error

func EchoCustomHTTPErrorHandler

func EchoCustomHTTPErrorHandler(err error, c echo.Context)

Types

type CustomJSONData

type CustomJSONData struct{}

func CustomJSON

func CustomJSON() *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 {
	Code        string `json:"code"`
	Description string `json:"description"`
	Data        any    `json:"data"`
	Internal    error  `json:"-"`
}

type SeaweedFSData added in v1.1.0

type SeaweedFSData struct {
	URL string
}

func NewSeaweedFS added in v1.1.0

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

func (*SeaweedFSData) Delete added in v1.1.0

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

func (*SeaweedFSData) Download added in v1.1.0

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

func (*SeaweedFSData) Upload added in v1.1.0

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