{"id":13567347,"url":"https://github.com/magnetikonline/action-golang-cache","last_synced_at":"2025-05-02T01:30:24.007Z","repository":{"id":45703941,"uuid":"410469249","full_name":"magnetikonline/action-golang-cache","owner":"magnetikonline","description":"GitHub Action bringing together actions/setup-go and actions/cache.","archived":false,"fork":false,"pushed_at":"2024-03-07T22:52:32.000Z","size":13,"stargazers_count":36,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T06:10:46.599Z","etag":null,"topics":["cache","github-actions","golang"],"latest_commit_sha":null,"homepage":"","language":null,"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/magnetikonline.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-09-26T06:25:29.000Z","updated_at":"2025-02-18T22:19:34.000Z","dependencies_parsed_at":"2024-06-21T17:39:16.758Z","dependency_job_id":"eacaf48c-ead6-428a-ae82-91b542c98af5","html_url":"https://github.com/magnetikonline/action-golang-cache","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"70438cdca8992490bd968e4c28468183a530f5a8"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Faction-golang-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Faction-golang-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Faction-golang-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Faction-golang-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magnetikonline","download_url":"https://codeload.github.com/magnetikonline/action-golang-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250922279,"owners_count":21508303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cache","github-actions","golang"],"created_at":"2024-08-01T13:02:29.044Z","updated_at":"2025-05-02T01:30:23.728Z","avatar_url":"https://github.com/magnetikonline.png","language":null,"funding_links":[],"categories":["Misc"],"sub_categories":[],"readme":"# Action Golang with cache\n\nComposite GitHub Action combining a perfect pairing of [actions/setup-go](https://github.com/actions/setup-go) with [actions/cache](https://github.com/actions/cache) for caching of both Golang module and build caches.\n\n![nuts and gum](https://user-images.githubusercontent.com/1818757/134792061-2fb04549-ed6d-4e4d-a805-3de6ea90f261.jpg)\n\n- [Usage](#usage)\n- [Setting unique cache keys](#setting-unique-cache-keys)\n- [Action outputs](#action-outputs)\n\n## Usage\n\nReduce all these workflow steps:\n\n```yaml\nsteps:\n  - name: Setup Golang\n    uses: actions/setup-go@v5\n    with:\n      go-version: ~1.22\n  - name: Setup Golang caches\n    uses: actions/cache@v4\n    with:\n      path: |\n        ~/.cache/go-build\n        ~/go/pkg/mod\n      key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}\n      restore-keys: |\n        ${{ runner.os }}-golang-\n```\n\ndown to this:\n\n```yaml\nsteps:\n  - name: Setup Golang with cache\n    uses: magnetikonline/action-golang-cache@v5\n    with:\n      go-version: ~1.22\n```\n\nor better yet, use `go-version-file` for version selection:\n\n```yaml\nsteps:\n  - name: Setup Golang with cache\n    uses: magnetikonline/action-golang-cache@v5\n    with:\n      go-version-file: go.mod\n```\n\nAction correctly saves/restores **build** and **module** cache paths for Linux, macOS _and_ Windows runners.\n\n## Setting unique cache keys\n\nAn optional `cache-key-suffix` input allows control of the generated cache key. This is handy where different Golang program(s) are tested/compiled across multiple workflow definitions - resulting in unique optimized build cache path contents:\n\n```yaml\nsteps:\n  - name: Cache key suffix\n    uses: magnetikonline/action-golang-cache@v5\n    with:\n      go-version: ~1.22\n      cache-key-suffix: apples\n\n# cache key:   ${{ runner.os }}-golang-apples-${{ hashFiles('**/go.sum') }}\n# restore key: ${{ runner.os }}-golang-apples-\n```\n\n## Action outputs\n\nOutputs of `build-cache-path`, `module-cache-path` and `cache-key` are provided - handy for use in subsequent workflow steps, such as with `actions/cache/save`:\n\n```yaml\nsteps:\n  - name: Setup Golang with cache\n    id: golang-with-cache\n    uses: magnetikonline/action-golang-cache@v5\n    with:\n      go-version-file: go.mod\n\n  # further steps...\n\n  - name: Save Golang cache\n    if: always()\n    uses: actions/cache/save@v4\n    with:\n      path: |\n        ${{ steps.golang-with-cache.outputs.build-cache-path }}\n        ${{ steps.golang-with-cache.outputs.module-cache-path }}\n      key: ${{ steps.golang-with-cache.outputs.cache-key }}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetikonline%2Faction-golang-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnetikonline%2Faction-golang-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetikonline%2Faction-golang-cache/lists"}