{"id":32435332,"url":"https://github.com/matttproud/gofencefmt","last_synced_at":"2026-04-17T15:33:40.994Z","repository":{"id":320263219,"uuid":"1050016990","full_name":"matttproud/gofencefmt","owner":"matttproud","description":"Binary gofencefmt reformats Go code that appears in Markdown code fences.","archived":false,"fork":false,"pushed_at":"2025-10-23T10:26:11.000Z","size":25,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-10T18:52:39.433Z","etag":null,"topics":["go","markdown","nvim","vim"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matttproud.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-03T20:32:10.000Z","updated_at":"2025-10-31T13:49:40.000Z","dependencies_parsed_at":"2025-10-22T21:36:46.817Z","dependency_job_id":null,"html_url":"https://github.com/matttproud/gofencefmt","commit_stats":null,"previous_names":["matttproud/gofencefmt"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/matttproud/gofencefmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matttproud%2Fgofencefmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matttproud%2Fgofencefmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matttproud%2Fgofencefmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matttproud%2Fgofencefmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matttproud","download_url":"https://codeload.github.com/matttproud/gofencefmt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matttproud%2Fgofencefmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31934352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T12:37:54.787Z","status":"ssl_error","status_checked_at":"2026-04-17T12:37:25.095Z","response_time":62,"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":["go","markdown","nvim","vim"],"created_at":"2025-10-25T22:51:25.065Z","updated_at":"2026-04-17T15:33:40.969Z","avatar_url":"https://github.com/matttproud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gofencefmt\n\ngofencefmt is a tool to reformat blocks of Go code (in the spirit of `gofmt`)\nthat appear in a Markdown code fence.\n\n## Motivating Examples\n\nLet's consider some examples:\n\nIn the simplest case, we have a code snippet that is not indented correctly.\n\n```go\n// Input:\npackage main\n\nfunc songThatNeverEnds() {\nitGoesOn()\nandOn()\nmyFriends()\n}\n```\n\nIf you run gofencefmt on the fence's contents, it will produce this:\n\n```go\n// Output:\npackage main\n\nfunc songThatNeverEnds() {\n\titGoesOn()\n\tandOn()\n\tmyFriends()\n}\n```\n\nNote that the code is indented even with Go's native tabs. Now, that isn't all\nthat interesting in and of itself, so let's consider some more interesting\ncases:\n\n1. **Indented Fences**: Below we have an indented code fence that is a child\n   of this Markdown list item. It's also malformatted.\n\n   ```go\n   // Input:\n   package main\n\n   func songThatNeverEnds() {\n   itGoesOn()\n   andOn()\n   myFriends()\n   }\n   ```\n\n   When gofencefmt is run on the literal text range of the indented fence, it\n   ensures the output matches the same fundamental level of Markdown\n   indentation.\n\n   ```go\n   // Output:\n   package main\n\n   func songThatNeverEnds() {\n   \titGoesOn()\n   \tandOn()\n   \tmyFriends()\n   }\n   ```\n\n2. **Supports Snippet**: Sometimes when writing code snippets, we like to excerpt\n   top-level identifiers without them being part of a whole program.\n\n   ```go\n   // Input:\n   func songThatNeverEnds() {\n   itGoesOn()\n   andOn()\n   myFriends()\n   }\n   ```\n\n   gofencefmt handles these just fine:\n\n   ```go\n   // Output:\n   func songThatNeverEnds() {\n   \titGoesOn()\n   \tandOn()\n   \tmyFriends()\n   }\n   ```\n\n   **Note:** There is no `package` clause in the snippet above!\n\n   gofencefmt can even do this for code snippets that would appear inline in a\n   function (or method).\n\n   ```go\n   // Input:\n   for isSongThatNeverEnds() {\n   itGoesOn()\n   andOn()\n   myFriends()\n   }\n   ```\n\n   And even output them in the most concise and indentation-correct way:\n\n   ```go\n   // Output:\n   for isSongThatNeverEnds() {\n   \titGoesOn()\n   \tandOn()\n   \tmyFriends()\n   }\n   ```\n\n## Installation\n\nUse the standard `go install` workflow as follows:\n\n```shell\n% go install github.com/matttproud/gofencefmt@latest\n```\n\n## Usage\n\nI have been using this with Vim and Neovim through the `!` program filter\ndirective. I use visual line mode to select the range of interest, which is\nexclusively the Go code in the code fence, and enter the command `:!\ngofencefmt`.\n\nLet's imagine Vim open as such:\n\n````\n    ```go {.good}\nVL  func Test(t *testing.T) {\nVL  // elided\nVL  if diff := cmp.Diff(want, got); diff != \"\" {\nVL    t.Errorf(\"f() = %v, want %v diff (-want, got):\\n\\n%v\", got, want, diff)\nVL  }\nVL  // elided\nVL  }\n    ```\n````\n\nHere the lines prefixed with \"VL\" indicate these lines have been selected in\nvisual line mode (**Note:** \"VL\" is an annotation I am providing, nothing you\nwill see in Vim). After the visual selection has been made, run\n`:! gofencefmt`.\n\nI have **not** tested this gofencefmt with [`conform.nvim`]'s [injected\nlanguage formatting]. I presume it would work in some capacity.\n\n[`conform.nvim`]: https://github.com/stevearc/conform.nvim\n[injected language formatting]: https://github.com/stevearc/conform.nvim/blob/master/doc/advanced_topics.md#injected-language-formatting-code-blocks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatttproud%2Fgofencefmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatttproud%2Fgofencefmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatttproud%2Fgofencefmt/lists"}