{"id":26930290,"url":"https://github.com/limitcool/lib","last_synced_at":"2026-07-10T11:31:50.370Z","repository":{"id":215766582,"uuid":"739730562","full_name":"limitcool/lib","owner":"limitcool","description":"This is a Go language library that provides some useful functions to facilitate rapid development.","archived":false,"fork":false,"pushed_at":"2024-08-10T04:18:14.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-10T05:26:23.396Z","etag":null,"topics":["function","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/limitcool.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":"2024-01-06T11:21:00.000Z","updated_at":"2024-08-10T05:26:25.568Z","dependencies_parsed_at":null,"dependency_job_id":"fcd704f5-9c9e-49a8-9275-d6c5f94053eb","html_url":"https://github.com/limitcool/lib","commit_stats":null,"previous_names":["limitcool/lib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limitcool%2Flib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limitcool%2Flib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limitcool%2Flib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limitcool%2Flib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limitcool","download_url":"https://codeload.github.com/limitcool/lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763881,"owners_count":20829800,"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":["function","go","golang"],"created_at":"2025-04-02T06:18:16.366Z","updated_at":"2025-10-29T04:05:55.778Z","avatar_url":"https://github.com/limitcool.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/limitcool/lib.svg)](https://pkg.go.dev/github.com/limitcool/lib)\n[![Go Report Card](https://goreportcard.com/badge/github.com/limitcool/lib)](https://goreportcard.com/report/github.com/limitcool/lib)\n\nThis is a Go language library that provides some useful functions to facilitate rapid development.\n\n[中文自述在这里.](README.zh_cn.md)\n\n## Installation\n\nTo use this library, you need to install it in your project. You can install it by running the following command:\n\n```bash\ngo get github.com/limitcool/lib\n```\n\n## Function List\n\n### Debugging and Environment\n\n- `SetDebugMode(debugFunction func())`: Set the debug mode based on the environment variable and execute a debug function.\n\n### Slice Manipulation\n\n- `InSlice(element T, Slice []T) bool`: Check if an element exists in a slice.\n- `Unique(slice []T) []T`: Remove duplicate elements from a slice.\n- `Push(slice []T, element T) []T`: Add an element to the end of a slice.\n- `Pop(slice []T) ([]T, T)`: Remove and return the last element from a slice.\n- `PopFront(slice []T) ([]T, T)`: Remove and return the first element from a slice.\n- `Exclude(slice []T, element T) []T`: Return a slice without the specified element.\n- `Reverse(s []T) []T`: Reverse the order of elements in a slice.\n\n### Map Manipulation\n\n- `Keys(m map[K]V) []K`: Return a slice containing all the keys in a map.\n\n### Type Conversion\n\n- `IntToBool(a T) bool`: Convert an integer to a boolean value.\n- `ConvertAnyToInterface(anyValue *any.Any) (interface{}, error)`: Convert Google's protobuf `any.Any` type to Go's `interface{}` type.\n- `ConvertInterfaceToAny(v interface{}) (*any.Any, error)`: Convert Go's `interface{}` type to Google's protobuf `any.Any` type.\n- `MustConvertInterfaceToAny(v interface{}) *any.Any`: Similar to `ConvertInterfaceToAny`, but ignores errors.\n- `MustConvertAnyToInterface(anyValue *any.Any) interface{}`: Similar to `ConvertAnyToInterface`, but ignores errors.\n\n### File and Folder Operations\n\n- `FileExists(filename string) bool`: Check if a file exists.\n- `FolderExists(foldername string) bool`: Check if a folder exists.\n- `FilesInFolder(dir, filename string) ([]string, error)`: Return a list of file paths containing the specified file in the given directory.\n- `ReadFile(filename string) (string, error)`: Read the content of a file and return it.\n- `CopyDir(src, dst, skip string) error`: Copy a directory from the source path to the destination path, skipping files with a specific suffix.\n- `CopyDirHasSuffix(src, dst, suffix string) error`: Copy files with a specific suffix from the source directory to the destination directory, renaming the copied files.\n- `CopyFile(src, dst string) error`: Copy a single file from the source path to the destination path.\n- `ParentDir(p string) string`: Return the parent directory of the given path.\n- `BaseDir(p string) string`: Return the base directory of the given path.\n- `ParentBaseDir(p string) string`: Return the parent base directory of the given path.\n- `CompressDir(dir string) error`: Compress the specified directory into a zip file.\n\n### Hashing and Encryption\n\n- `GetSha256Hash(str string) string`: Calculate the SHA-256 hash value of the given string and return it.\n\n### Web\n\n- `GetPage(c *gin.Context, DefaultPageSize int)`: Calculate the offset based on the page number parameter from the request and return it.\n- `ParseToken(token, secret string)`: Parse and validate the given token, and return the claims contained in it along with any potential errors.\n\n### MongoDB Specific\n\n- `MustMongoSlice2StringSlice(i interface{}) []string`: Convert a MongoDB slice type to a Go string slice type, ignoring errors.\n- `MongoSlice2StringSlice(i interface{}) ([]string, error)`: Convert a MongoDB slice type to a Go string slice type, returning errors.\n\n## Usage Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/limitcool/lib\"\n)\n\nfunc main() {\n    slice := []int{1, 2, 3, 4, 3}\n    uniqueSlice := lib.Unique(slice)\n    fmt.Println(uniqueSlice) // Output: [1 2 3 4]\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimitcool%2Flib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimitcool%2Flib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimitcool%2Flib/lists"}