{"id":19468614,"url":"https://github.com/maktoobgar/go_telegram_bot_template","last_synced_at":"2026-06-16T15:31:43.196Z","repository":{"id":121181621,"uuid":"463955830","full_name":"maktoobgar/go_telegram_bot_template","owner":"maktoobgar","description":"A telegram bot template in golang for fast setup in projects.","archived":false,"fork":false,"pushed_at":"2022-02-27T16:29:38.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T15:07:23.472Z","etag":null,"topics":["go","golang","telebot","telegram-bot","template-repository"],"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/maktoobgar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","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}},"created_at":"2022-02-26T20:12:19.000Z","updated_at":"2022-07-16T13:25:26.000Z","dependencies_parsed_at":"2024-01-16T18:58:52.809Z","dependency_job_id":"816e9b76-357a-4561-a00e-ccbaa503dd08","html_url":"https://github.com/maktoobgar/go_telegram_bot_template","commit_stats":null,"previous_names":["maktoobgar/go_telegram_template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/maktoobgar/go_telegram_bot_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maktoobgar%2Fgo_telegram_bot_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maktoobgar%2Fgo_telegram_bot_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maktoobgar%2Fgo_telegram_bot_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maktoobgar%2Fgo_telegram_bot_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maktoobgar","download_url":"https://codeload.github.com/maktoobgar/go_telegram_bot_template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maktoobgar%2Fgo_telegram_bot_template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34412786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","golang","telebot","telegram-bot","template-repository"],"created_at":"2024-11-10T18:42:40.172Z","updated_at":"2026-06-16T15:31:43.178Z","avatar_url":"https://github.com/maktoobgar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What Is This?\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/golang.png\"\u003e\u003c/img\u003e\n\u003c/p\u003e\n\nAt this project, I'm trying to create a fully extendable golang template for creating telegram bot with **Clean** structure and come up with a reusable, nice and scalable base for any telegram project and ofcourse reusable codes and some separate packages.\n\nIf you do love to contribute, please do, I appreciate it.\n\nDon't forget to read [CONTRIBUTING](/CONTRIBUTING.md) file to know about how to contribute in this project.\n\n## Quick Start\n\n1. Install Dependencies:\n   * ```\n     go get -v github.com/rubenv/sql-migrate/...\n     go mod tidy\n     ```\n   * **Note**: For migrations you most likely need `sql-migrate`.\n2. Copy and paste these lines in your terminal when you're inside project root directory:\n   * ```bash\n      cp dbconfig_example.yml dbconfig.yml\n      cp env_example.yml env.yml\n      ```\n   * Those example files(env_example.yml and dbconfig_example.yml) have ready configurations for a quick start for the project.\n3. Change value of `bot_token` and `developer_id` by your own bot token and your own id which you can get from [userinfobot](http://t.me/userinfobot).\n4. How to run:\n   * ```bash\n     go run ./cmd/main/main.go\n     ```\n\n## Clean Structure\n\nIf you don't have any idea about **clean** structure, please just take a moment and just have a look at it first and after understanding the structure, come back here and continue.\n\n**Note**: If you know about clean structure, understanding folders usages will make more sense.\n\n## Config Loading\n\nThe [`cfg.go`][cfg.go] file (if the [config files](#config-files) are passed just right) fills attributes in [`global.go`][global.go].\n\nJust to load everything right up, you have to import [`cfg.go`][cfg.go] file like:\n```\n_ \"github.com/maktoobgar/go_telegram_template/internal/app/load\"\n```\n\n**Note**: You don't need to do that, I'm just describing what is happening.\n\n## Config Files\n\nThere is a file named [config.go][config.go] inside `internal/config` folder which **defines structures** for config files of the project.\\\n**Main config files**, which have some default configs in them and no coding happens in them, are inside `build` folder and the default config file named [`config.yaml`][config.yaml] is inside `build/config` address.\\\nTake a look at them and you get whats going on.\n\n## What Is `g`? (important)\n\n`g` stands for **global**. In this project, I created a file named [`global.go`][global.go] inside `internal/global` folder to have all config files for the project in one place and access them as fast as possible.\\\nIn down documentation you may see me mention using `g.Something`, just know that I meant [global.go][global.go] file and I assume you know that you have to import it like `g \"github.com/maktoobgar/go_telegram_template/internal/global\"` to use `g`.\n\n### Update Default Configs\n\nIf you want to update default config file([`config.yaml`][config.yaml] file), you may add a file to the root project directory named `env.yaml` or `env.yml` and override any configs you need to and replace you new desired configs.\n\n## Translation\n\nIf you need to translate anything in your application, use `g.Translator` object to do it and don't forget to add your translation to `build/translations` folder like other files that you can use as an example in that directory.\n\n**Note**: If you want to be so contractual, you can have interface of `g.Translator` by calling `g.Trans()` function and then do your translations like:\n```\ng.Trans().TranslateEN(\"my word\")\n```\n\n### New Languages\n\nIf you need new languages(Persian and English added by default), you can add them by first updating `languages` variable inside [cfg.go][cfg.go] file and then at least create an empty file for that variable inside `build/translations` folder like [translation.fa.json][translation.fa.json] file.\n\n## Query Builder\n\nIn this project I added [`goqu`][goqu] query builder, if you need to learn how to use it, read [goqu][goqu] example files inside their repo. (files followed by `_example_test.go` at the end are example files)\\\nIf you take a look at [config.go][config.go] file, you can see that in `Database` structure, there is a `Name` attribute inside them.\\\nThat `Name` attribute will be used to give you an access to your databases, after config files successfully loaded, you can use `Name` attribute of your database to access their query builder to make changes on your databases just by calling `g.Postgres[Name]` or `g.Sqlite[Name]` or `g.MySQL[Name]` or `g.SqlServer[Name]`.\nPlease attention that a database connection with their `Name` equal to `main`, will be places inside `g.DB` separately from others just for fast access to your main database connection.\n\n**Note**: Connections to these databases are inside `g.PostgresCons`, `g.SqliteCons`, `g.MySQLCons` and `g.SqlServerCons`.\n\n## Adding Service\n\nThe services path is `internal/services` and inside that you can create a folder, name it whatever you want and add a file in it and start writing you service. There are examples in `internal/services` folder that you can have a look at them.\n\n**Note**: I strongly recommend you to add a service for every tables you have in your database.\n\n**Note**: If you want to follow up some more recommendations, create your interfaces or your popular structures(you use them somewhere else) for your services inside `internal/contract` folder.\n\n[config.yaml]: build/config/config.yaml\n[cfg.go]: internal/app/load/cfg.go\n[global.go]: internal/global/global.go\n[config.go]: internal/config/config.go\n[translation.fa.json]: build/translations/translation.fa.json\n[goqu]: https://github.com/doug-martin/goqu\n[fiber]: https://docs.gofiber.io/\n[sql-migrate]: https://github.com/rubenv/sql-migrate","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaktoobgar%2Fgo_telegram_bot_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaktoobgar%2Fgo_telegram_bot_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaktoobgar%2Fgo_telegram_bot_template/lists"}