{"id":13413804,"url":"https://github.com/huydang284/fixedwidth","last_synced_at":"2026-01-26T10:07:44.953Z","repository":{"id":57502269,"uuid":"201713195","full_name":"huydang284/fixedwidth","owner":"huydang284","description":"A Go package for encode/decode fixed-width data","archived":false,"fork":false,"pushed_at":"2019-12-20T03:18:01.000Z","size":80,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:52:53.836Z","etag":null,"topics":["decoding","encoder-decoder","encoding","fixed-width","fixedwidth","go","golang"],"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/huydang284.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}},"created_at":"2019-08-11T03:42:24.000Z","updated_at":"2023-10-01T22:40:50.000Z","dependencies_parsed_at":"2022-09-13T07:02:07.504Z","dependency_job_id":null,"html_url":"https://github.com/huydang284/fixedwidth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/huydang284/fixedwidth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huydang284%2Ffixedwidth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huydang284%2Ffixedwidth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huydang284%2Ffixedwidth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huydang284%2Ffixedwidth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huydang284","download_url":"https://codeload.github.com/huydang284/fixedwidth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huydang284%2Ffixedwidth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28774299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T09:42:00.929Z","status":"ssl_error","status_checked_at":"2026-01-26T09:42:00.591Z","response_time":59,"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":["decoding","encoder-decoder","encoding","fixed-width","fixedwidth","go","golang"],"created_at":"2024-07-30T20:01:49.767Z","updated_at":"2026-01-26T10:07:44.938Z","avatar_url":"https://github.com/huydang284.png","language":"Go","readme":"# Fixedwidth\n[![Build Status](https://travis-ci.org/huydang284/fixedwidth.svg?branch=master)](https://travis-ci.org/huydang284/fixedwidth)\n[![Report](https://goreportcard.com/badge/github.com/huydang284/fixedwidth)](https://goreportcard.com/badge/github.com/huydang284/fixedwidth)\n[![Code coverage](https://codecov.io/gh/huydang284/fixedwidth/branch/master/graph/badge.svg)](https://codecov.io/gh/huydang284/fixedwidth)\n\nFixedwidth is a Go package that provides a simple way to define fixed-width data, fast encoding and decoding also is the project's target.\n\n## Character encoding supported\nUTF-8\n\n## Getting Started\n### Installation\nTo start using Fixedwidth, run `go get`:\n``` \n$ go get github.com/huydang284/fixedwidth\n```\n\n### How we limit a struct field\nTo limit a struct field, we use `fixed` tag.\n\nExample:\n```go\ntype people struct {\n    Name string `fixed:\"10\"`\n    Age  int    `fixed:\"3\"`\n}\n```\n\nIf the value of struct field is longer than the limit that we defined, redundant characters will be truncated.\n\nOtherwise, if the value of struct field is less than the limit, additional spaces will be appended.\n\n### Encoding\nWe can use `Marshal` function directly to encode fixed-width data.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/huydang284/fixedwidth\"\n)\n\ntype people struct {\n    Name string `fixed:\"10\"`\n    Age  int    `fixed:\"3\"`\n}\n\nfunc main() {\n    me := people {\n        Name: \"Huy\",\n        Age: 25,\n    }\n    data, _ := fixedwidth.Marshal(me)\n    fmt.Println(string(data))\n}\n```\n\nThe result will be:\n```\nHuy       25 \n```\n\n### Decoding\nFor decoding, we use `Unmarshal`.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/huydang284/fixedwidth\"\n)\n\ntype people struct {\n    Name string `fixed:\"10\"`\n    Age  int    `fixed:\"3\"`\n}\n\nfunc main() {\n    var me people\n    data := []byte(\"Huy       25 \")\n    fixedwidth.Unmarshal(data, \u0026me)\n    fmt.Printf(\"%+v\", me)\n}\n```\n\nThe result will be:\n```\n{Name:Huy Age:25}\n```\n\n## Author\nHuy Dang ([huydangg28@gmail.com](mailto:huydangg28@gmail.com))\n\n## License\nFixedwidth source code is available under the [MIT License](https://github.com/huydang284/fixedwidth/blob/master/LICENSE).","funding_links":[],"categories":["Serialization","序列化","Relational Databases","安全领域相关库"],"sub_categories":["HTTP Clients","HTTP客户端","查询语"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuydang284%2Ffixedwidth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuydang284%2Ffixedwidth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuydang284%2Ffixedwidth/lists"}