{"id":37213305,"url":"https://github.com/omigo/light","last_synced_at":"2026-01-15T00:36:20.715Z","repository":{"id":43726624,"uuid":"57189740","full_name":"omigo/light","owner":"omigo","description":"Generate Go/Golang database/sql query code, spirit from MyBatis/iBatis.","archived":false,"fork":false,"pushed_at":"2021-02-07T03:37:03.000Z","size":3680,"stargazers_count":84,"open_issues_count":0,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-06-21T06:08:17.279Z","etag":null,"topics":["generate","gobatis","ibatis","mybatis","mysql","orm","osm","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omigo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-27T06:36:06.000Z","updated_at":"2023-08-16T14:17:23.000Z","dependencies_parsed_at":"2022-09-02T06:11:34.863Z","dependency_job_id":null,"html_url":"https://github.com/omigo/light","commit_stats":null,"previous_names":["arstd/yan","arstd/light"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/omigo/light","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omigo","download_url":"https://codeload.github.com/omigo/light/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omigo%2Flight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28439814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:34:46.850Z","status":"ssl_error","status_checked_at":"2026-01-15T00:34:46.551Z","response_time":107,"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":["generate","gobatis","ibatis","mybatis","mysql","orm","osm","sql"],"created_at":"2026-01-15T00:36:20.022Z","updated_at":"2026-01-15T00:36:20.706Z","avatar_url":"https://github.com/omigo.png","language":"Go","readme":"light [![Build Status](https://api.travis-ci.org/omigo/light.svg?branch=master)](https://api.travis-ci.org/omigo/light.svg?branch=master)\n=====\n\n\n\n`light` is a tool for generating database query code from go source file with\ninterface methods commented with SQLs and Variables.\n\n`Interface methods commented with SQL and variables` =\u003e `go generate`=\u003e `Database query code implementation`\n\n![light.jpg](light.jpg)\n\n### Usage\n\nInstall `light` tool. Make sure $GOBIN in your $PATH environment.\n\n    `go get -u -v github.com/omigo/light`\n\nRun `light -h`, check install.\n\n    # light -h\n    Usage of light:\n      -log\n        \tGenerated file with log\n\nDefine a interface, and comment methods with SQLs and Variables, then write a directive `//go:generate light`.\n\n```go\n//go:generate light -log -timeout 30\n\ntype User interface {\n    // UPDATE users\n    // SET [username=?,]\n    //     [phone=?,]\n    //     [address=?,]\n    //     [status=?,]\n    //     [birthday=?,]\n    //     updated=CURRENT_TIMESTAMP\n    // WHERE id=?\n    Update(u *model.User) (int64, error)\n}\n```\n\nAfter that, run `go generate ./...`, code generated.\n\n\t# go generate ./...\n\tSource file    /Users/Arstd/Reposits/src/github.com/omigo/light/example/store/user.go\n\tGenerated file /Users/Arstd/Reposits/src/github.com/omigo/light/example/store/user.light.go\n\n```go\n\ntype UserStore struct{}\n\nfunc (*UserStore) Update(u *model.User) (int64, error) {\n\tvar buf bytes.Buffer\n\tvar args []interface{}\n\tbuf.WriteString(`UPDATE users SET `)\n\tif u.Username != \"\" {\n\t\tbuf.WriteString(`username=?, `)\n\t\targs = append(args, u.Username)\n\t}\n\tif u.Phone != \"\" {\n\t\tbuf.WriteString(`phone=?, `)\n\t\targs = append(args, null.String(\u0026u.Phone))\n\t}\n\tif u.Address != nil {\n\t\tbuf.WriteString(`address=?, `)\n\t\targs = append(args, u.Address)\n\t}\n\tif u.Status != 0 {\n\t\tbuf.WriteString(`status=?, `)\n\t\targs = append(args, null.Uint8(\u0026u.Status))\n\t}\n\tif u.Birthday != nil {\n\t\tbuf.WriteString(`birthday=?, `)\n\t\targs = append(args, u.Birthday)\n\t}\n\tbuf.WriteString(`updated=CURRENT_TIMESTAMP WHERE id=? `)\n\targs = append(args, null.Uint64(\u0026u.Id))\n\tquery := buf.String()\n\tlog.Debug(query)\n\tlog.Debug(args...)\n\tres, err := db.Exec(query, args...)\n\tif err != nil {\n\t\tlog.Error(query)\n\t\tlog.Error(args...)\n\t\tlog.Error(err)\n\t\treturn 0, err\n\t}\n\treturn res.RowsAffected()\n}\n```\n\n### More\n\nComplete demo in example.\n\nSource interface: [example/store/user.go](example/store/user.go)\n\nGenerated code: [example/store/user.light.go](example/store/user.light.go)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomigo%2Flight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomigo%2Flight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomigo%2Flight/lists"}