{"id":27880866,"url":"https://github.com/atomicgo/convert","last_synced_at":"2025-05-05T04:39:02.745Z","repository":{"id":255594897,"uuid":"853085502","full_name":"atomicgo/convert","owner":"atomicgo","description":"📐 Convert strings to integers, or Astronomical Units to Gigameter - we got you covered!","archived":false,"fork":false,"pushed_at":"2024-09-06T02:18:10.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-06T07:28:42.722Z","etag":null,"topics":["atomicgo","convert","go","golang","golang-library","hacktoberfest","units"],"latest_commit_sha":null,"homepage":"https://atomicgo.dev","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/atomicgo.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},"funding":{"github":["MarvinJWendt"]}},"created_at":"2024-09-06T00:54:59.000Z","updated_at":"2024-09-06T02:18:13.000Z","dependencies_parsed_at":"2024-09-06T07:38:49.363Z","dependency_job_id":null,"html_url":"https://github.com/atomicgo/convert","commit_stats":null,"previous_names":["atomicgo/convert"],"tags_count":1,"template":false,"template_full_name":"atomicgo/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconvert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconvert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconvert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconvert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicgo","download_url":"https://codeload.github.com/atomicgo/convert/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252442480,"owners_count":21748448,"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":["atomicgo","convert","go","golang","golang-library","hacktoberfest","units"],"created_at":"2025-05-05T04:39:00.336Z","updated_at":"2025-05-05T04:39:02.726Z","avatar_url":"https://github.com/atomicgo.png","language":"Go","funding_links":["https://github.com/sponsors/MarvinJWendt"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\n\n\n┌───────────────────────────────────────────────────────────────────┐\n│                                                                   │\n│                          IMPORTANT NOTE                           │\n│                                                                   │\n│               This file is automatically generated                │\n│           All manual modifications will be overwritten            │\n│                                                                   │\n└───────────────────────────────────────────────────────────────────┘\n\n\n\n--\u003e\n\n\u003ch1 align=\"center\"\u003eAtomicGo | convert\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fconvert\u0026style=flat-square\" alt=\"Downloads\"\u003e\n\n\u003ca href=\"https://github.com/atomicgo/convert/releases\"\u003e\n\u003cimg src=\"https://img.shields.io/github/v/release/atomicgo/convert?style=flat-square\" alt=\"Latest Release\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/convert\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/atomicgo/convert/go.yml?style=flat-square\" alt=\"Tests\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/convert\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/codecov/c/gh/atomicgo/convert?color=magenta\u0026logo=codecov\u0026style=flat-square\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/convert\"\u003e\n\u003c!-- unittestcount:start --\u003e\u003cimg src=\"https://img.shields.io/badge/Unit_Tests-34-magenta?style=flat-square\" alt=\"Unit test count\"\u003e\u003c!-- unittestcount:end --\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square\" alt=\"License: MIT\"\u003e\n\u003c/a\u003e\n  \n\u003ca href=\"https://goreportcard.com/report/github.com/atomicgo/convert\" target=\"_blank\"\u003e\n\u003cimg src=\"https://goreportcard.com/badge/github.com/atomicgo/convert?style=flat-square\" alt=\"Go report\"\u003e\n\u003c/a\u003e   \n\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003e\u003ca href=\"https://pkg.go.dev/atomicgo.dev/convert#section-documentation\" target=\"_blank\"\u003eDocumentation\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md\" target=\"_blank\"\u003eContributing\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CODE_OF_CONDUCT.md\" target=\"_blank\"\u003eCode of Conduct\u003c/a\u003e\u003c/strong\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/atomicgo/atomicgo/main/assets/header.png\" alt=\"AtomicGo\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\u003ch3  align=\"center\"\u003e\u003cpre\u003ego get atomicgo.dev/convert\u003c/pre\u003e\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\n\u003c!-- gomarkdoc:embed:start --\u003e\n\n\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n# convert\n\n```go\nimport \"atomicgo.dev/convert\"\n```\n\nPackage convert contains many functions for converting between different go types and units.\n\n\n\n\n\n```go\npackage main\n\nimport ()\n\nfunc main() {\n}\n```\n\n\n\n## Index\n\n- [func Length\\(value float64, from, to LengthUnit\\) float64](\u003c#Length\u003e)\n- [type LengthUnit](\u003c#LengthUnit\u003e)\n\n\n\u003ca name=\"Length\"\u003e\u003c/a\u003e\n## func [Length](\u003chttps://github.com/atomicgo/convert/blob/main/length.go#L60\u003e)\n\n```go\nfunc Length(value float64, from, to LengthUnit) float64\n```\n\nLength converts a length value from one unit to another.\n\nWarning: Due to the nature of floating point arithmetic, the result may not be exact for some conversions. Do not use this package for rocket science.\n\n\n\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"atomicgo.dev/convert\"\n)\n\nfunc main() {\n\tresult := convert.Length(1, convert.Inch, convert.Centimeter)\n\tfmt.Println(result)\n\n}\n```\n\n#### Output\n\n```\n2.54\n```\n\n\n\n\u003ca name=\"LengthUnit\"\u003e\u003c/a\u003e\n## type [LengthUnit](\u003chttps://github.com/atomicgo/convert/blob/main/length.go#L3\u003e)\n\n\n\n```go\ntype LengthUnit float64\n```\n\n\u003ca name=\"Nanometer\"\u003e\u003c/a\u003e\n\n```go\nconst (\n    // Metric system\n    Nanometer  LengthUnit = 9.999999999e-10     // Nanometer to meter conversion\n    Micrometer LengthUnit = 0.000001            // Micrometer to meter conversion\n    Millimeter LengthUnit = 0.001               // Millimeter to meter conversion\n    Centimeter LengthUnit = 0.01                // Centimeter to meter conversion\n    Decimeter  LengthUnit = 0.1                 // Decimeter to meter conversion\n    Meter      LengthUnit = 1                   // Meter is the base unit\n    Decameter  LengthUnit = 10                  // Decameter to meter conversion\n    Hectometer LengthUnit = 100                 // Hectometer to meter conversion\n    Kilometer  LengthUnit = 1000                // Kilometer to meter conversion\n    Megameter  LengthUnit = 1000000             // Megameter to meter conversion\n    Gigameter  LengthUnit = 1000000000          // Gigameter to meter conversion\n    Terameter  LengthUnit = 1000000000000       // Terameter to meter conversion\n    Petameter  LengthUnit = 1000000000000000    // Petameter to meter conversion\n    Exameter   LengthUnit = 1000000000000000000 // Exameter to meter\n    Micron     LengthUnit = 0.000001            // Micron to meter conversion\n    Picometer  LengthUnit = 1e-12               // Picometer to meter conversion\n    Femtometer LengthUnit = 9.999999999e-16     // Femtometer to meter conversion\n    Attometer  LengthUnit = 1e-18               // Attometer to meter conversion\n\n    // Imperial system\n    Thou         LengthUnit = 2.54e-5  // Thou (mil) to meter conversion\n    Inch         LengthUnit = 0.0254   // Inch to meter conversion\n    Foot         LengthUnit = 0.3048   // Foot to meter conversion\n    Yard         LengthUnit = 0.9144   // Yard to meter conversion\n    Chain        LengthUnit = 20.1168  // Chain to meter conversion (66 feet)\n    Rope         LengthUnit = 6.096    // Rope to meter conversion (20 feet)\n    Furlong      LengthUnit = 201.168  // Furlong to meter conversion (1/8th of a mile)\n    Mile         LengthUnit = 1609.344 // Mile to meter conversion\n    League       LengthUnit = 4828.032 // League to meter conversion (3 miles)\n    NauticalMile LengthUnit = 1852     // Nautical Mile to meter conversion (international)\n\n    // Astronomical units\n    AstronomicalUnit LengthUnit = 149597870691         // Astronomical Unit (AU) to meter conversion\n    LightYear        LengthUnit = 9460730472580044     // Light-year to meter conversion\n    Parsec           LengthUnit = 30856775812799588    // Parsec to meter conversion\n    Megaparsec       LengthUnit = 3.085677581e+22      // Megaparsec to meter\n    Kiloparsec       LengthUnit = 30856775812799586000 // Kiloparsec to meter\n    PlanckLength     LengthUnit = 1.616049999e-35      // Planck length to meter conversion\n\n    // Other units\n    Angstrom   LengthUnit = 9.999999999e-11 // Angstrom to meter conversion\n    Fathom     LengthUnit = 1.8288          // Fathom to meter conversion (6 feet)\n    Rod        LengthUnit = 5.0292          // Rod to meter conversion (16.5 feet)\n    SurveyFoot LengthUnit = 0.3048006096    // Survey foot to meter conversion (used in land surveys)\n    Pica       LengthUnit = 0.0042333333    // Pica to meter conversion (commonly used in typography)\n    Point      LengthUnit = 0.0003527778    // Point to meter conversion (1/12th of a pica)\n    Hand       LengthUnit = 0.1016          // Hand to meter conversion (used in measuring the height of horses)\n)\n```\n\nGenerated by [gomarkdoc](\u003chttps://github.com/princjef/gomarkdoc\u003e)\n\n\n\u003c!-- gomarkdoc:embed:end --\u003e\n\n---\n\n\u003e [AtomicGo.dev](https://atomicgo.dev) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e with ❤️ by [@MarvinJWendt](https://github.com/MarvinJWendt) |\n\u003e [MarvinJWendt.com](https://marvinjwendt.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fconvert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicgo%2Fconvert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fconvert/lists"}