{"id":22973202,"url":"https://github.com/gabrielhcataldo/go-helper","last_synced_at":"2025-04-02T07:14:51.305Z","repository":{"id":220014933,"uuid":"735039934","full_name":"GabrielHCataldo/go-helper","owner":"GabrielHCataldo","description":"🛠️ Powerful, complete and open source utility library written in Go.","archived":false,"fork":false,"pushed_at":"2024-05-31T16:35:56.000Z","size":245,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T21:42:51.633Z","etag":null,"topics":["generic-types","go-util","go-utils","helpers","helpers-library","utilities","utility","utils","utils-library"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/GabrielHCataldo/go-helper/helper","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GabrielHCataldo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-23T12:59:35.000Z","updated_at":"2024-05-31T16:35:49.000Z","dependencies_parsed_at":"2024-05-31T15:05:49.923Z","dependency_job_id":null,"html_url":"https://github.com/GabrielHCataldo/go-helper","commit_stats":null,"previous_names":["gabrielhcataldo/go-helper"],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GabrielHCataldo%2Fgo-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GabrielHCataldo","download_url":"https://codeload.github.com/GabrielHCataldo/go-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246769968,"owners_count":20830771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generic-types","go-util","go-utils","helpers","helpers-library","utilities","utility","utils","utils-library"],"created_at":"2024-12-14T23:40:15.721Z","updated_at":"2025-04-02T07:14:51.266Z","avatar_url":"https://github.com/GabrielHCataldo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Go Helper\n=================\n\u003c!--suppress ALL --\u003e\n\u003cimg align=\"right\" src=\"gopher-helper.png\" alt=\"\"\u003e\n\n[![Project status](https://img.shields.io/badge/version-v1.8.1-vividgreen.svg)](https://github.com/GabrielHCataldo/go-helper/releases/tag/v1.8.1)\n[![Go Report Card](https://goreportcard.com/badge/github.com/GabrielHCataldo/go-helper)](https://goreportcard.com/report/github.com/GabrielHCataldo/go-helper)\n[![Coverage Status](https://coveralls.io/repos/GabrielHCataldo/go-helper/badge.svg?branch=main\u0026service=github)](https://coveralls.io/github/GabrielHCataldo/go-helper?branch=main)\n[![Open Source Helpers](https://www.codetriage.com/gabrielhcataldo/go-helper/badges/users.svg)](https://www.codetriage.com/gabrielhcataldo/go-helper)\n[![GoDoc](https://godoc.org/github/GabrielHCataldo/go-helper?status.svg)](https://pkg.go.dev/github.com/GabrielHCataldo/go-helper/helper)\n![License](https://img.shields.io/dub/l/vibe-d.svg)\n\n[//]: # ([![build workflow]\u0026#40;https://github.com/GabrielHCataldo/go-helper/actions/workflows/go.yml/badge.svg\u0026#41;]\u0026#40;https://github.com/GabrielHCataldo/go-helper/actions\u0026#41;)\n\n[//]: # ([![Source graph]\u0026#40;https://sourcegraph.com/github.com/go-helper/helper/-/badge.svg\u0026#41;]\u0026#40;https://sourcegraph.com/github.com/go-helper/helper?badge\u0026#41;)\n\n[//]: # ([![TODOs]\u0026#40;https://badgen.net/https/api.tickgit.com/badgen/github.com/GabrielHCataldo/go-helper/helper\u0026#41;]\u0026#40;https://www.tickgit.com/browse?repo=github.com/GabrielHCataldo/go-helper\u0026#41;)\n\nThe go-helper project came to facilitate the use of validations, conversions, formatting in your go project with\nincredible flexibility and simple to use. Below we list some implemented features:\n\n- No more using !=, ==, \u003e, among others, start using better described functions for this.\n- It is not necessary to use more len to check if it is empty or not, or greater than the same, just pass the values into intuitive functions.\n- Use robust validation functions out of the box.\n- Check all types of possible values in a simple and intuitive way.\n- Check single or multiple values if they are empty, null, equal, etc. without having to write lines and lines of code.\n- Easy rounding functions.\n- Format and Convert functions for you to use in the best way in your projects, without having to write repetitive lines of code.\n- Help us be the best and most complete golang utility library and help the community.\n\nInstallation\n------------\n\nUse go get.\n\n\tgo get github.com/GabrielHCataldo/go-helper\n\nThen import the go-helper package into your own code.\n\n```go\nimport \"github.com/GabrielHCataldo/go-helper/helper\"\n```\n\nUsability and documentation\n------------\n**IMPORTANT**: Always check the documentation in the structures and functions fields.\nFor more details on the examples, visit [All examples link](https://github/GabrielHCataldo/go-helper/blob/main/_example)\n\n### Empty validate\nTo check if the values are empty, just do as in the example below,\nremembering that we also accept values of any type, see:\n\n```go\npackage main\n\nimport (\n    \"github.com/GabrielHCataldo/go-helper/helper\"\n    \"log\"\n    \"time\"\n)\n\ntype exampleStruct struct {\n    Name      string\n    BirthDate time.Time\n    Map       map[string]any\n}\n\nfunc main() {\n    // empty validations\n    nStruct := exampleStruct{}\n    nString := \"  \"\n    isEmpty := helper.IsEmpty(nStruct, nString)\n    log.Println(\"is empty?\", isEmpty)\n    nString = \"test name\"\n    nStruct.Name = nString\n    isNotEmpty := helper.IsNotEmpty(\u0026nStruct, nString)\n    log.Println(\"is not empty?\", isNotEmpty)\n\t\n    //return B value if A value is empty\n    var a1 string\n    var b1 string\n    a1 = \"a value is not empty\"\n    result := helper.IfEmptyReturns(a1, b1)\n    log.Println(\"result not empty:\", result)\n\t\n    //return value not empty\n    var a2 string\n    var b2 string\n    b2 = \"b value is not empty\"\n    result = helper.ReturnNonEmptyValue(a2, b2)\n    log.Println(\"result not empty:\", result)\n}\n```\n\nOutputs:\n\n    is empty? true\n    is not empty? true\n    result not empty: a value is not empty\n    result not empty: b value is not empty\n\nSee other types of values as examples by accessing\nthe [link](https://github/GabrielHCataldo/go-helper/blob/main/_example/empty/main.go).\n\n### Nil validate\nValidating “nil” values is simple, but be careful as\nonly the types **Pointer**, **Map**, **Chan**, **Interface** and **Slice**\ncan have a null value in go, see an example below:\n\n```go\npackage main\n\nimport (\n    \"github.com/GabrielHCataldo/go-helper/helper\"\n    \"log\"\n)\n\nfunc main() {\n    var anyPointer *any\n    var anotherValue []any\n    isNil := helper.IsNil(anyPointer, anotherValue)\n    log.Println(\"is nil?\", isNil)\n    anyPointer = helper.ConvertToPointer(any(\"value string\"))\n    anotherValue = []any{12, \"test\"}\n    isNotNil := helper.IsNotNil(anyPointer, anotherValue)\n    log.Println(\"is not nil?\", isNotNil)\n    \n    //return B value if A value is nil\n    var a1 *string\n    var b1 string\n    b1 = \"b value is not nil\"\n    result1 := helper.IfNilReturns(a1, b1)\n    log.Println(\"result not nil:\", result1)\n    \n    //return value not nil\n    var a2 *string\n    var b2 *string\n    v2 := \"a value is not nil\"\n    a2 = \u0026v2\n    result2 := helper.ReturnNonNilValue(a2, b2)\n    log.Println(\"result not nil:\", result2)\n}\n\n```\n\nOutputs:\n\n    is nil? true\n    is not nil? true\n    result not nil: 0x14000223150\n    result not nil: 0x1400025d7f0\n\nSee other types of values as examples by accessing\nthe [link](https://github/GabrielHCataldo/go-helper/blob/main/_example/empty/main.go).\n\n### Equals validate\nChecking equal is very simple, and works for any type and number \nof parameters entered, if it is **Pointer**, go-helper will obtain the\nreal value for comparison, see one of the examples:\n\n```go\npackage main\n\nimport (\n    \"github.com/GabrielHCataldo/go-helper/helper\"\n    \"log\"\n)\n\nfunc main() {\n    s1 := \"value\"\n    s2 := \"value\"\n    s3 := \"value\"\n    s4 := \"value\"\n    \n    equals := helper.Equals(s1, s2, s3, s4)\n    log.Println(\"equals?\", equals)\n    \n    s1 = \"value1\"\n    \n    notEquals := helper.IsNotEqualTo(s1, s2, s3, s4)\n    log.Println(\"not equals?\", notEquals)\n\n    s1 = \"VaLuE\"\n    s2 = \"VaLuE\"\n    s3 = \"VaLuE\"\n    s4 = \"VaLuE\"\n\n    equals = helper.EqualsIgnoreCase(s1, s2, s3, s4)\n    log.Println(\"equals ignore case?\", equals)\n\n    s1 = \"value1\"\n\n    notEquals = helper.IsNotEqualToIgnoreCase(s1, s2, s3, s4)\n    log.Println(\"not equals ignore case?\", notEquals)\n}\n```\n\nOutputs:\n\n    equals? true\n    not equals? true\n    equals ignore case? true\n    not equals ignore case? true\n\nSee other types of values as examples by accessing\nthe [link](https://github/GabrielHCataldo/go-helper/blob/main/_example/equal/main.go).\n\n### Type validate\nWith go-helper it is very simple to know the type of your variable, see the example:\n\n```go\npackage main\n\nimport (\n    \"github.com/GabrielHCataldo/go-helper/helper\"\n    \"log\"\n    \"time\"\n)\n\nfunc main() {\n    var a any = map[string]any{}\n    \n    // for negative use IsNotMap\n    isMap := helper.IsMapType(a)\n    log.Println(\"is map?\", isMap)\n    \n    a = \"value1\"\n\n    // for negative use IsNotString\n    isString := helper.IsStringType(a)\n    log.Println(\"is string?\", isString)\n    \n    a = 12\n\t\n    // for negative use IsNotIntType\n    isInt := helper.IsIntType(a)\n    log.Println(\"is int?\", isInt)\n    \n    a = true\n\n    // for negative use IsNotBoolType\n    isBool := helper.IsBoolType(a)\n    log.Println(\"is bool?\", isBool)\n    \n    a = time.Now()\n\n    // for negative use IsNotTimeType\n    isTime := helper.IsTimeType(a)\n    log.Println(\"is time?\", isTime)\n}\n```\n\nOutputs:\n\n    is map? true\n    is string? true\n    is int? true\n    is bool? true\n    is time? true\n\nSee other types of values as examples by accessing\nthe [link](https://github/GabrielHCataldo/go-helper/blob/main/_example/type/main.go).\n\n### Convert\nWith go-helper you don't need to worry about laborious and repetitive conversions to implement, see a powerful \nexample of conversion from any type A to any type B:\n\n```go\npackage main\n\nimport (\n    \"github.com/GabrielHCataldo/go-helper/helper\"\n    \"log\"\n    \"time\"\n)\n\ntype exampleStruct struct {\n    Name      string\n    BirthDate time.Time\n    Map       map[string]any\n}\n\nfunc main() {\n    var destStruct exampleStruct\n    // convert to struct to string base64, it's funny and sample\n    s64 := helper.SimpleConvertToBase64(initExampleStruct())\n    // convert string base64 to struct\n    err := helper.ConvertToDest(s64, \u0026destStruct)\n    if helper.IsNotNil(err) {\n        log.Println(\"error convert base64 to struct:\", err)\n        return\n    }\n    log.Println(\"converted base64 to struct:\", destStruct)\n    var destMap map[string]any\n    // convert struct to simple map\n    err = helper.ConvertToDest(destStruct, \u0026destMap)\n    if helper.IsNotNil(err) {\n        log.Println(\"error convert struct to map:\", err)\n        return\n    }\n    log.Println(\"converted struct to map:\", destMap)\n}\n\nfunc initExampleStruct() exampleStruct {\n    return exampleStruct{\n        Name:      \"Foo Bar\",\n        BirthDate: time.Now(),\n        Map:       map[string]any{\"example\": 1, \"test\": 2},\n    }\n}\n```\n\nOutput:\n\n    [INFO 2024/01/17 09:09:00] main.go:26: converted base64 to struct: {\"Name\":\"Foo Bar\",\"BirthDate\":\"2024-01-17T09:08:49-03:00\",\"Map\":{\"example\":1,\"test\":2}}\n    [INFO 2024/01/17 09:09:00] main.go:34: converted struct to map: {\"Name\":\"Foo Bar\",\"BirthDate\":\"2024-01-17T09:08:49.038335-03:00\",\"Map\":{\"example\":1,\"test\":2}}\n\nSee other types of values as examples by accessing\nthe [link](https://github/GabrielHCataldo/go-helper/blob/main/_example/convert/main.go).\n\n### For more examples\n\n- [Empty](https://github/GabrielHCataldo/go-helper/blob/main/_example/empty/main.go)\n- [Equal](https://github/GabrielHCataldo/go-helper/blob/main/_example/equal/main.go)\n- [Float](https://github/GabrielHCataldo/go-helper/blob/main/_example/float/main.go)\n- [Format](https://github/GabrielHCataldo/go-helper/blob/main/_example/format/main.go)\n- [Convert](https://github/GabrielHCataldo/go-helper/blob/main/_example/convert/main.go)\n- [Int](https://github/GabrielHCataldo/go-helper/blob/main/_example/int/main.go)\n- [String](https://github/GabrielHCataldo/go-helper/blob/main/_example/string/main.go)\n- [Time](https://github/GabrielHCataldo/go-helper/blob/main/_example/time/main.go)\n- [Type](https://github/GabrielHCataldo/go-helper/blob/main/_example/type/main.go)\n- [Validate](https://github/GabrielHCataldo/go-helper/blob/main/_example/validate/main.go)\n- [Validator](https://github/GabrielHCataldo/go-helper/blob/main/_example/validator/main.go)\n\nThanks\n------\n- https://github.com/go-playground/validator/v10\n- https://github.com/klassmann/cpfcnpj\n- https://github.com/nyaruka/phonenumbers\n- https://github.com/leekchan/accounting\n\nHow to contribute\n------\nMake a pull request, or if you find a bug, open it\nan Issues.\n\nLicense\n-------\nDistributed under MIT license, see the license file within the code for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielhcataldo%2Fgo-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrielhcataldo%2Fgo-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrielhcataldo%2Fgo-helper/lists"}