{"id":13413940,"url":"https://github.com/ianlopshire/go-fixedwidth","last_synced_at":"2026-01-22T15:03:10.588Z","repository":{"id":29158313,"uuid":"110886422","full_name":"ianlopshire/go-fixedwidth","owner":"ianlopshire","description":"Encoding and decoding for fixed-width formatted data","archived":false,"fork":false,"pushed_at":"2024-02-08T23:36:46.000Z","size":92,"stargazers_count":86,"open_issues_count":10,"forks_count":36,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-08T13:47:09.313Z","etag":null,"topics":["decoding","encoding","fixed-width"],"latest_commit_sha":null,"homepage":"http://godoc.org/github.com/ianlopshire/go-fixedwidth","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/ianlopshire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2017-11-15T21:05:44.000Z","updated_at":"2025-05-09T07:11:33.000Z","dependencies_parsed_at":"2024-02-09T00:24:01.756Z","dependency_job_id":"751afd83-8200-4164-bfd4-7479471b7d15","html_url":"https://github.com/ianlopshire/go-fixedwidth","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/ianlopshire/go-fixedwidth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlopshire%2Fgo-fixedwidth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlopshire%2Fgo-fixedwidth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlopshire%2Fgo-fixedwidth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlopshire%2Fgo-fixedwidth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ianlopshire","download_url":"https://codeload.github.com/ianlopshire/go-fixedwidth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlopshire%2Fgo-fixedwidth/sbom","scorecard":{"id":478498,"data":{"date":"2025-08-11","repo":{"name":"github.com/ianlopshire/go-fixedwidth","commit":"df11b762147215a5b7e8ead6af03f22bc2ed4538"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":4,"reason":"Found 8/18 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/ianlopshire/go-fixedwidth/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/ianlopshire/go-fixedwidth/go.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: GoBuiltInFuzzer integration found: fuzz_test.go:13"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T15:56:04.721Z","repository_id":29158313,"created_at":"2025-08-19T15:56:04.721Z","updated_at":"2025-08-19T15:56:04.721Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["decoding","encoding","fixed-width"],"created_at":"2024-07-30T20:01:53.240Z","updated_at":"2026-01-22T15:03:10.559Z","avatar_url":"https://github.com/ianlopshire.png","language":"Go","readme":"# fixedwidth [![GoDoc](https://godoc.org/github.com/ianlopshire/go-fixedwidth?status.svg)](http://godoc.org/github.com/ianlopshire/go-fixedwidth) [![Report card](https://goreportcard.com/badge/github.com/ianlopshire/go-fixedwidth)](https://goreportcard.com/report/github.com/ianlopshire/go-fixedwidth) [![Go Cover](http://gocover.io/_badge/github.com/ianlopshire/go-fixedwidth)](http://gocover.io/github.com/ianlopshire/go-fixedwidth)\n\nPackage fixedwidth provides encoding and decoding for fixed-width formatted Data.\n\n`go get github.com/ianlopshire/go-fixedwidth`\n\n## Usage\n\n### Struct Tags\n\nThe struct tag schema schema used by fixedwidth is: `fixed:\"{startPos},{endPos},[{alignment},[{padChar}]]\"`\u003csup id=\"a1\"\u003e[1](#f1)\u003c/sup\u003e.\n\nThe `startPos` and `endPos` arguments control the position within a line. `startPos` and `endPos` must both be positive integers greater than 0. Positions start at 1. The interval is inclusive. \n\nThe `alignment` argument controls the alignment of the value within it's interval. The valid options are `default`\u003csup id=\"a2\"\u003e[2](#f2)\u003c/sup\u003e, `right`, `left`, and `none`. The `alignment` is optional and can be omitted.\n\nThe `padChar` argument controls the character that will be used to pad any empty characters in the interval after writing the value. The default padding character is a space. The `padChar` is optional and can be omitted.\n\nFields without tags are ignored.\n\n### Encode\n```go\n// define some data to encode\npeople := []struct {\n    ID        int     `fixed:\"1,5\"`\n    FirstName string  `fixed:\"6,15\"`\n    LastName  string  `fixed:\"16,25\"`\n    Grade     float64 `fixed:\"26,30\"`\n    Age       uint    `fixed:\"31,33\"`\n    Alive     bool    `fixed:\"34,39\"`\n}{\n    {1, \"Ian\", \"Lopshire\", 99.5, 20, true},\n}\n\ndata, err := Marshal(people)\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Printf(\"%s\", data)\n// Output:\n// 1    Ian       Lopshire  99.5020 true\n```\n\n### Decode\n```go\n// define the format\nvar people []struct {\n    ID        int     `fixed:\"1,5\"`\n    FirstName string  `fixed:\"6,15\"`\n    LastName  string  `fixed:\"16,25\"`\n    Grade     float64 `fixed:\"26,30\"`\n    Age       uint    `fixed:\"31,33\"`\n    Alive     bool    `fixed:\"34,39\"`\n    Github    bool    `fixed:\"40,41\"`\n}\n\n// define some fixed-with data to parse\ndata := []byte(\"\" +\n    \"1    Ian       Lopshire  99.50 20 false f\" + \"\\n\" +\n    \"2    John      Doe       89.50 21 true t\" + \"\\n\" +\n    \"3    Jane      Doe       79.50 22 false F\" + \"\\n\" +\n    \"4    Ann       Carraway  79.59 23 false T\" + \"\\n\")\n\nerr := Unmarshal(data, \u0026people)\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"%+v\\n\", people[0])\nfmt.Printf(\"%+v\\n\", people[1])\nfmt.Printf(\"%+v\\n\", people[2])\nfmt.Printf(\"%+v\\n\", people[3])\n// Output:\n//{ID:1 FirstName:Ian LastName:Lopshire Grade:99.5 Age:20 Alive:false Github:false}\n//{ID:2 FirstName:John LastName:Doe Grade:89.5 Age:21 Alive:true Github:true}\n//{ID:3 FirstName:Jane LastName:Doe Grade:79.5 Age:22 Alive:false Github:false}\n//{ID:4 FirstName:Ann LastName:Carraway Grade:79.59 Age:23 Alive:false Github:true}\n```\n\nIt is also possible to read data incrementally\n\n```go\ndecoder := fixedwidth.NewDecoder(bytes.NewReader(data))\nfor {\n    var element myStruct\n    err := decoder.Decode(\u0026element)\n    if err == io.EOF {\n        break\n    }\n    if err != nil {\n        log.Fatal(err)\n    }\n    handle(element)\n}\n```\n\n### UTF-8, Codepoints, and Multibyte Characters\n\nfixedwidth supports encoding and decoding fixed-width data where indices are expressed in\nunicode codepoints and not raw bytes. The data must be UTF-8 encoded.\n\n```go\ndecoder := fixedwidth.NewDecoder(strings.NewReader(data))\ndecoder.SetUseCodepointIndices(true)\n// Decode as usual now\n```\n\n\n```go\nbuff := new(bytes.Buffer)\nencoder := fixedwidth.NewEncoder(buff)\nencoder.SetUseCodepointIndices(true)\n// Encode as usual now\n```\n\n### Alignment Behavior\n\n| Alignment | Encoding | Decoding |\n| --------- | -------- | -------- |\n| `default` | Field is left aligned | The padding character is trimmed from both right and left of value |\n| `left` | Field is left aligned | The padding character is trimmed from right of value |\n| `right` | Field is right aligned | The padding character is trimmed from left of value |\n| `none` | Field is left aligned | The padding character is not trimmed from value. Useful for nested structs. |\n\n## Notes\n1. \u003cspan id=\"f1\"\u003e`{}` indicates an argument. `[]` indicates and optional segment [^](#a1)\u003c/span\u003e\n2. \u003cspan id=\"f2\"\u003eThe `default` alignment is similar to `left` but has slightly different behavior required to maintain backwards compatibility [^](#a2)\u003c/span\u003e \n\n## Licence\nMIT\n","funding_links":[],"categories":["Text Processing","文本处理","Bot Building","Specific Formats","Template Engines","\u003cspan id=\"文字处理-text-processing\"\u003e文字处理 Text Processing\u003c/span\u003e"],"sub_categories":["Advanced Console UIs","格式器","Formatters","HTTP Clients","查询语","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianlopshire%2Fgo-fixedwidth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianlopshire%2Fgo-fixedwidth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianlopshire%2Fgo-fixedwidth/lists"}