{"id":37154533,"url":"https://github.com/alexandermac/gosu","last_synced_at":"2026-01-14T18:14:37.070Z","repository":{"id":196217261,"uuid":"695171948","full_name":"AlexanderMac/gosu","owner":"AlexanderMac","description":"A package for self updating Go applications","archived":false,"fork":false,"pushed_at":"2024-11-27T10:22:30.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-27T11:25:46.637Z","etag":null,"topics":[],"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/AlexanderMac.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-09-22T14:07:16.000Z","updated_at":"2024-11-27T10:22:18.000Z","dependencies_parsed_at":"2024-11-27T11:22:56.598Z","dependency_job_id":"2e56ec74-96da-4fc7-be2c-7df0f0aa2dc8","html_url":"https://github.com/AlexanderMac/gosu","commit_stats":null,"previous_names":["alexandermac/gosu"],"tags_count":3,"template":false,"template_full_name":"AlexanderMac/go-app-template","purl":"pkg:github/AlexanderMac/gosu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderMac%2Fgosu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderMac%2Fgosu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderMac%2Fgosu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderMac%2Fgosu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderMac","download_url":"https://codeload.github.com/AlexanderMac/gosu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderMac%2Fgosu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28430130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":"2026-01-14T18:14:36.175Z","updated_at":"2026-01-14T18:14:37.065Z","avatar_url":"https://github.com/AlexanderMac.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003egosu\u003c/h1\u003e\n  \u003cp\u003eA package for self updating Go applications\u003c/p\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/alexandermac/gosu/actions/workflows/ci.yml?query=branch%3Amaster\"\u003e\u003cimg src=\"https://github.com/alexandermac/gosu/actions/workflows/ci.yml/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/alexandermac/gosu\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/alexandermac/gosu\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/alexandermac/gosu\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/alexandermac/gosu.svg\" alt=\"Go Docs\"\u003e\u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/alexandermac/gosu.svg\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://img.shields.io/github/v/tag/alexandermac/gosu\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/alexandermac/gosu\" alt=\"GitHub tag\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\nA package for self updating Go applications. Gets the latest application release from the project's Github repository (public or private), when a new version is detected, downloads the update archive, upgrades the application and restarts it automatically.\nWorks in Windows and Linux.\n\nWorks in Go v1.18+.\n\n# Contents\n- [Contents](#contents)\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [License](#license)\n\n# Install\n```sh\ngo get github.com/alexandermac/gosu\n```\n\n# Usage\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/alexandermac/gosu\"\n)\n\ntype AppUpdater struct {\n\tgosu *gosu.Updater\n}\n\nfunc NewUpdater(appVersion string) AppUpdater {\n\treturn AppUpdater{\n\t\tgosu: gosu.New(\n\t\t\tos.Getenv(\"GH_ORG_NAME\"),     // organization name + project name\n\t\t\tos.Getenv(\"GH_ACCESS_TOKEN\"), // github access token to access private repos\n\t\t\tappVersion,                   // local version of the app\n\t\t),\n\t}\n}\n\nfunc (updater *AppUpdater) CheckUpdates() bool {\n\tresult := updater.gosu.CheckUpdates()\n\n\tswitch result.Code {\n\tcase gosu.CODE_LATEST_VERSION_IS_ALREADY_IN_USE, gosu.CODE_UNRELEASED_VERSION_IS_IN_USE, gosu.CODE_NEW_VERSION_DETECTED:\n\t\tfmt.Println(\"\u003e\u003e\u003e\", result.Message, result.Details)\n\tcase gosu.CODE_ERROR:\n\t\terr := fmt.Errorf(\"%s. %s\", result.Message, result.Details)\n\t\tlog.Panic(err)\n\t}\n\n\treturn result.Code == gosu.CODE_NEW_VERSION_DETECTED\n}\n\nfunc (updater *AppUpdater) DownloadUpdate() bool {\n\tprogressCh := make(chan gosu.DownloadingProgress)\n\tgo func() {\n\t\tfor {\n\t\t\tprogress, ok := \u003c-progressCh\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Printf(\"Asset downloading progress: %d/%d\\n\", progress.CurrentSize, progress.TotalSize)\n\t\t}\n\t}()\n\n\tresult := updater.gosu.DownloadAsset(progressCh)\n\tswitch result.Code {\n\tcase gosu.CODE_DOWNLOADING_CANCELLED, gosu.CODE_DOWNLOADING_COMPLETED:\n\t\tfmt.Println(\"\u003e\u003e\u003e\", result.Message, result.Details)\n\tcase gosu.CODE_ERROR:\n\t\terr := fmt.Errorf(\"%s. %s\", result.Message, result.Details)\n\t\tlog.Panic(err)\n\t}\n\n\treturn result.Code == gosu.CODE_DOWNLOADING_COMPLETED\n}\n\nfunc (updater *AppUpdater) CancelDownloading() {\n\tupdater.gosu.CancelAssetDownloading()\n}\n\nfunc (updater *AppUpdater) UpdateApp() {\n\tresult := updater.gosu.UpdateApp()\n\tswitch result.Code {\n\tcase gosu.CODE_ERROR:\n\t\terr := fmt.Errorf(\"%s. %s\", result.Message, result.Details)\n\t\tlog.Panic(err)\n\t}\n}\n\nfunc main() {\n\tupdater := NewUpdater(\"1.3.0\")\n\tresult := updater.CheckUpdates()\n\tif !result {\n\t\treturn\n\t}\n\n\tgo func() {\n\t\ttime.Sleep(time.Second * 5)\n\t\tupdater.CancelDownloading()\n\t}()\n\tresult = updater.DownloadUpdate()\n\tif !result {\n\t\treturn\n\t}\n\n\tupdater.UpdateApp()\n}\n\n```\n\n# API\n\n### New(orgRepoName, ghAccessToken, localVersion string) *Updater\nCreates a new instance of `gosu.Updater`.\n\n```go\ngosu := gosu.New(\n\t\"alexandermac/superapp\", // organization name + project name\n\t\"\",                      // github access token to access private repos\n\t\"1.3.0\",                 // local version of the app\n)\n```\n\n### SetLogger(l Logger)\nSets a custom logger instead of the standard `log` used by default. The provided logger must satisfy the `Logger` interface.\n\n```go\ngosu.SetLogger(logrus.StandardLogger())\n```\n\n### CheckUpdates() UpdateResult\nChecks for application's updates. Returns struct with code and message indicating that new version exists or not. \n\n### DownloadAsset(progressCh chan\u003c- DownloadingProgress) UpdateResult\nDownloads a release asset. Accepts an optional channel to get downloading progress notifications.\n\n### CancelAssetDownloading()\nCancels an asset downloading.\n\n### UpdateApp() UpdateResult\nInstalls the downloaded update.\n\n# License\nLicensed under the MIT license.\n\n# Author\nAlexander Mac\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandermac%2Fgosu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandermac%2Fgosu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandermac%2Fgosu/lists"}