{"id":15379248,"url":"https://github.com/ducksoupdev/go-do","last_synced_at":"2026-04-24T03:35:25.643Z","repository":{"id":213299843,"uuid":"733525447","full_name":"ducksoupdev/go-do","owner":"ducksoupdev","description":"Digital Ocean Golang helpers","archived":false,"fork":false,"pushed_at":"2024-01-05T06:33:49.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T00:30:47.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ducksoupdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-19T14:21:28.000Z","updated_at":"2023-12-19T14:38:52.000Z","dependencies_parsed_at":"2024-11-15T22:34:26.535Z","dependency_job_id":"affae483-863a-4ff4-a526-c6fe80efa5cf","html_url":"https://github.com/ducksoupdev/go-do","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"a2118f5a9c7a1ab0f3c913b1afa6a17c16f55a31"},"previous_names":["ducksoupdev/go-do"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ducksoupdev/go-do","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducksoupdev%2Fgo-do","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducksoupdev%2Fgo-do/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducksoupdev%2Fgo-do/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducksoupdev%2Fgo-do/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ducksoupdev","download_url":"https://codeload.github.com/ducksoupdev/go-do/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ducksoupdev%2Fgo-do/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32208473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-01T14:18:38.159Z","updated_at":"2026-04-24T03:35:25.629Z","avatar_url":"https://github.com/ducksoupdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Digital Ocean Golang Helpers\n\nThis is a collection of helpers for working with Digital Ocean Apps/Functions using Golang\n\n## Installation\n\nThis library is compatible with modern Go releases in module mode, with Go installed:\n\n```bash\ngo get github.com/ducksoupdev/go-do/functions\n```\n\nwill resolve and add the package to the current development module, along with its dependencies.\n\nAlternatively the same can be achieved if you use import in a package:\n\n```go\nimport \"github.com/ducksoupdev/go-do/functions\"\n```\n\nand run `go get` without parameters.\n\n## Usage\n\nThere are structs, functions and methods for working with Digital Ocean Apps/Functions.\n\n### Headers struct\n\nThe `Headers` struct is used to set the headers for a JSON response. It has a predefined `ContentType: applicatiom/json` value.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  return \u0026functions.Response{\n    StatusCode: 200,\n    Headers:    functions.Headers,\n    Body:       string(jsonBody),\n  }, nil\n}\n```\n\n### Response struct\n\nThe `Response` struct is used to return a response from a function. It has `StatusCode`, `Headers` and `Body` fields.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  return \u0026functions.Response{\n    StatusCode: 200,\n    Headers:    functions.Headers,\n    Body:       string(jsonBody),\n  }, nil\n}\n```\n\n### Error response struct\n\nThe `ErrorResponse` struct is used to construct an error response in a function in conjunction with the `Response` struct. It has `Title`, `StatusCode` and `Detail` fields.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  errResponse, _ := json.Marshal(functions.ErrorResponse{\n    Title:      title,\n    StatusCode: statusCode,\n    Detail:     message,\n  })\n  return \u0026functions.Response{\n    StatusCode: statusCode,\n    Headers:    functions.Headers,\n    Body:       string(errResponse),\n  }, nil\n}\n```\n\nIt produces the following JSON response:\n\n```json\n{\n  \"title\": \"Bad Request\",\n  \"status\": 400,\n  \"detail\": \"No token provided\"\n}\n```\n\n### Error handler function\n\nThe `ErrorHandler` function is used to return an error response from a function using the `ErrorResponse` and `Response` structs.\nIt accepts `title`, `statusCode` and `message` arguments.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  return functions.ErrorHandler(functions.StatusCodeTitle(statusCode), statusCode, message)\n}\n```\n\n### Status code title function\n\nThe `StatusCodeTitle` function is used to return a title for a status code. It accepts a single `statusCode` argument.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  return functions.ErrorHandler(functions.StatusCodeTitle(statusCode), statusCode, message)\n}\n```\n\nThe title is returned from the following map:\n\n```go\nvar statusCodes = map[int]string{\n  100: \"Continue\",\n  101: \"Switching Protocols\",\n  102: \"Processing\",\n  103: \"Early Hints\",\n  200: \"OK\",\n  201: \"Created\",\n  202: \"Accepted\",\n  203: \"Non-Authoritative Information\",\n  204: \"No Content\",\n  205: \"Reset Content\",\n  206: \"Partial Content\",\n  207: \"Multi-Status\",\n  208: \"Already Reported\",\n  226: \"IM Used\",\n  300: \"Multiple Choices\",\n  301: \"Moved Permanently\",\n  302: \"Found\",\n  303: \"See Other\",\n  304: \"Not Modified\",\n  305: \"Use Proxy\",\n  306: \"Switch Proxy\",\n  307: \"Temporary Redirect\",\n  308: \"Permanent Redirect\",\n  400: \"Bad Request\",\n  401: \"Unauthorized\",\n  402: \"Payment Required\",\n  403: \"Forbidden\",\n  404: \"Not Found\",\n  405: \"Method Not Allowed\",\n  406: \"Not Acceptable\",\n  407: \"Proxy Authentication Required\",\n  408: \"Request Timeout\",\n  409: \"Conflict\",\n  410: \"Gone\",\n  411: \"Length Required\",\n  412: \"Precondition Failed\",\n  413: \"Payload Too Large\",\n  414: \"URI Too Long\",\n  415: \"Unsupported Media Type\",\n  416: \"Range Not Satisfiable\",\n  417: \"Expectation Failed\",\n  418: \"I'm a teapot\",\n  421: \"Misdirected Request\",\n  422: \"Unprocessable Entity\",\n  423: \"Locked\",\n  424: \"Failed Dependency\",\n  425: \"Too Early\",\n  426: \"Upgrade Required\",\n  428: \"Precondition Required\",\n  429: \"Too Many Requests\",\n  431: \"Request Header Fields Too Large\",\n  451: \"Unavailable For Legal Reasons\",\n  500: \"Internal Server Error\",\n  501: \"Not Implemented\",\n  502: \"Bad Gateway\",\n  503: \"Service Unavailable\",\n  504: \"Gateway Timeout\",\n  505: \"HTTP Version Not Supported\",\n  506: \"Variant Also Negotiates\",\n  507: \"Insufficient Storage\",\n  508: \"Loop Detected\",\n  510: \"Not Extended\",\n  511: \"Network Authentication Required\",\n}\n```\n\n### Contains function\n\nThe `Contains` function is used to check if a string is contained in a slice of strings. It accepts `slice` and `value` arguments.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  if functions.Contains([]string{\"one\", \"two\", \"three\"}, \"two\") {\n    // do something\n  }\n}\n```\n\n### ToStringArray function\n\nThe `ToStringArray` function is used to convert an interface to a slice of strings. It accepts a single `interface{}` argument.\n\n```go\nfunc Main(in Request) (*functions.Response, error) {\n  // do something\n\n  stringArray := functions.ToStringArray(in.Headers[\"X-Forwarded-For\"])\n}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details.\n\n## Contributing\n\nAny kind of positive contribution is welcome! Please help us to grow by contributing to the project.\n\nIf you wish to contribute, you can work on any features you think would enhance the library. After adding your code, please send us a Pull Request.\n\n\u003e Please read [CONTRIBUTING](CONTRIBUTING.md) for details on our [CODE OF CONDUCT](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us.\n\n## Support\n\nWe all need support and motivation. Please give this project a ⭐️ to encourage and show that you liked it. Don't forget to leave a star ⭐️ before you move away.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fducksoupdev%2Fgo-do","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fducksoupdev%2Fgo-do","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fducksoupdev%2Fgo-do/lists"}