{"id":21823673,"url":"https://github.com/godcong/dl","last_synced_at":"2026-02-23T08:33:15.693Z","repository":{"id":249159556,"uuid":"830494731","full_name":"godcong/dl","owner":"godcong","description":"Default value generates tools for Golang","archived":false,"fork":false,"pushed_at":"2025-04-01T20:45:45.000Z","size":107,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T04:41:19.313Z","etag":null,"topics":["default","go","injector","tag","tool"],"latest_commit_sha":null,"homepage":"","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/godcong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-18T11:39:02.000Z","updated_at":"2025-04-01T20:45:50.000Z","dependencies_parsed_at":"2024-07-22T11:55:06.522Z","dependency_job_id":"8068ea70-63e0-490a-a691-4c08d08f704b","html_url":"https://github.com/godcong/dl","commit_stats":null,"previous_names":["godcong/dl"],"tags_count":12,"template":false,"template_full_name":"origadmin/.github","purl":"pkg:github/godcong/dl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godcong%2Fdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godcong%2Fdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godcong%2Fdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godcong%2Fdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/godcong","download_url":"https://codeload.github.com/godcong/dl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godcong%2Fdl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29740008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: 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":["default","go","injector","tag","tool"],"created_at":"2024-11-27T17:36:02.699Z","updated_at":"2026-02-23T08:33:15.650Z","avatar_url":"https://github.com/godcong.png","language":"Go","readme":"# DL(Default Loader)\n\n## Overview\n\nDL (Default Loader) is a tool designed to generate and assign default values to fields within Go structs based on tags.\n\nThis utility allows you to specify default values for your struct fields using a simple tag syntax, \nmaking it easier to initialize structs with predefined values without having to explicitly set them in your code.\n\n---\n`defaults.go` is forked from [creasty/defaults](https://github.com/creasty/defaults) and modified to meet the requirements of this project.\n\n## Features\n\n- **Tag-based Default Values**: Use the `default` tag to set default values for struct fields.\n- **Easy Integration**: Quickly generate methods to load default values into your structs.\n- **Efficient Initialization**: Simplifies the initialization process of complex structs by automatically setting\n  default values.\n\n## Installation\n\nTo use DL (Default Loader), first install the tool via:\n\n```shell\ngo install github.com/godcong/dl/cmd@latest\n```\n\n## Usage\n\n### Step 1: Define Struct with Default Tags\n\nAdd the `default` tag to your struct fields to specify their default values:\n\n```go\n// example: demo.go\ntype Demo struct {\n    Name string `default:\"demo\"`\n}\n```\n\n### Step 2: Generate Default Value Loading Method\n\nRun DL to generate the necessary loading method for your struct, \nusing the `-f` flag to specify the file path with filename or directory:\n\n```shell\ndl -f ./demo.go\n```\n\nThis will generate a `Default() error` method in your struct that initializes the fields with the specified default values.\n\nBelow is the generated code example with `Demo` struct:\n```go\n// Default loads default values for Demo\nfunc (obj *Demo) Default() error {\n\tobj.Name = \"demo\"\n\treturn nil\n}\n```\n\n### Step 3: Load Default Values\n\nIn your code, use `dl.Load()` to populate your struct with the default values:\n\n```go\nfunc main() {\n    demo := \u0026Demo{}\n    if err := dl.Load(demo); err != nil {\n        panic(err)\n    } \n    // Now 'demo' has its fields initialized with default values. \n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodcong%2Fdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodcong%2Fdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodcong%2Fdl/lists"}