Skip to content

Commit 39ead6a

Browse files
docs: autoupdate
1 parent 45bd3ea commit 39ead6a

1 file changed

Lines changed: 91 additions & 41 deletions

File tree

README.md

Lines changed: 91 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@
1515
1616
-->
1717

18-
<h1 align="center">AtomicGo | template</h1>
18+
<h1 align="center">AtomicGo | convert</h1>
1919

2020
<p align="center">
21-
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Ftemplate&style=flat-square" alt="Downloads">
21+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fconvert&style=flat-square" alt="Downloads">
2222

23-
<a href="https://github.com/atomicgo/template/releases">
24-
<img src="https://img.shields.io/github/v/release/atomicgo/template?style=flat-square" alt="Latest Release">
23+
<a href="https://github.com/atomicgo/convert/releases">
24+
<img src="https://img.shields.io/github/v/release/atomicgo/convert?style=flat-square" alt="Latest Release">
2525
</a>
2626

27-
<a href="https://codecov.io/gh/atomicgo/template" target="_blank">
28-
<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/template/go.yml?style=flat-square" alt="Tests">
27+
<a href="https://codecov.io/gh/atomicgo/convert" target="_blank">
28+
<img src="https://img.shields.io/github/actions/workflow/status/atomicgo/convert/go.yml?style=flat-square" alt="Tests">
2929
</a>
3030

31-
<a href="https://codecov.io/gh/atomicgo/template" target="_blank">
32-
<img src="https://img.shields.io/codecov/c/gh/atomicgo/template?color=magenta&logo=codecov&style=flat-square" alt="Coverage">
31+
<a href="https://codecov.io/gh/atomicgo/convert" target="_blank">
32+
<img src="https://img.shields.io/codecov/c/gh/atomicgo/convert?color=magenta&logo=codecov&style=flat-square" alt="Coverage">
3333
</a>
3434

35-
<a href="https://codecov.io/gh/atomicgo/template">
36-
<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-3-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end -->
35+
<a href="https://codecov.io/gh/atomicgo/convert">
36+
<!-- unittestcount:start --><img src="https://img.shields.io/badge/Unit_Tests-34-magenta?style=flat-square" alt="Unit test count"><!-- unittestcount:end -->
3737
</a>
3838

3939
<a href="https://opensource.org/licenses/MIT" target="_blank">
4040
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT">
4141
</a>
4242

43-
<a href="https://goreportcard.com/report/github.com/atomicgo/template" target="_blank">
44-
<img src="https://goreportcard.com/badge/github.com/atomicgo/template?style=flat-square" alt="Go report">
43+
<a href="https://goreportcard.com/report/github.com/atomicgo/convert" target="_blank">
44+
<img src="https://goreportcard.com/badge/github.com/atomicgo/convert?style=flat-square" alt="Go report">
4545
</a>
4646

4747
</p>
4848

4949
---
5050

5151
<p align="center">
52-
<strong><a href="https://pkg.go.dev/atomicgo.dev/template#section-documentation" target="_blank">Documentation</a></strong>
52+
<strong><a href="https://pkg.go.dev/atomicgo.dev/convert#section-documentation" target="_blank">Documentation</a></strong>
5353
|
5454
<strong><a href="https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md" target="_blank">Contributing</a></strong>
5555
|
@@ -68,7 +68,7 @@
6868
</tbody>
6969
</table>
7070
</p>
71-
<h3 align="center"><pre>go get atomicgo.dev/template</pre></h3>
71+
<h3 align="center"><pre>go get atomicgo.dev/convert</pre></h3>
7272
<p align="center">
7373
<table>
7474
<tbody>
@@ -80,17 +80,13 @@
8080

8181
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
8282

83-
# template
83+
# convert
8484

8585
```go
86-
import "atomicgo.dev/template"
86+
import "atomicgo.dev/convert"
8787
```
8888

89-
Package template is used to generate new AtomicGo repositories.
90-
91-
Write the description of the module here. You can use \*\*markdown\*\*\! This description should clearly explain what the package does.
92-
93-
Example description: https://golang.org/src/encoding/gob/doc.go
89+
Package convert contains many functions for converting between different go types and units.
9490

9591

9692

@@ -99,38 +95,30 @@ Example description: https://golang.org/src/encoding/gob/doc.go
9995
```go
10096
package main
10197

102-
import (
103-
"fmt"
104-
105-
"atomicgo.dev/template"
106-
)
98+
import ()
10799

108100
func main() {
109-
fmt.Println(template.HelloWorld())
110101
}
111102
```
112103

113-
#### Output
114-
115-
```
116-
Hello, World!
117-
```
118-
119104

120105

121106
## Index
122107

123-
- [func HelloWorld\(\) string](<#HelloWorld>)
108+
- [func Length\(value float64, from, to LengthUnit\) float64](<#Length>)
109+
- [type LengthUnit](<#LengthUnit>)
124110

125111

126-
<a name="HelloWorld"></a>
127-
## func [HelloWorld](<https://github.com/atomicgo/template/blob/main/template.go#L4>)
112+
<a name="Length"></a>
113+
## func [Length](<https://github.com/atomicgo/convert/blob/main/length.go#L58>)
128114

129115
```go
130-
func HelloWorld() string
116+
func Length(value float64, from, to LengthUnit) float64
131117
```
132118

133-
HelloWorld returns \`Hello, World\!\`.
119+
Length converts a length value from one unit to another.
120+
121+
Warning: 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.
134122

135123

136124

@@ -142,22 +130,84 @@ package main
142130
import (
143131
"fmt"
144132

145-
"atomicgo.dev/template"
133+
"atomicgo.dev/convert"
146134
)
147135

148136
func main() {
149-
fmt.Println(template.HelloWorld())
137+
result := convert.Length(1, convert.Inch, convert.Centimeter)
138+
fmt.Println(result)
139+
150140
}
151141
```
152142

153143
#### Output
154144

155145
```
156-
Hello, World!
146+
2.54
157147
```
158148

159149

160150

151+
<a name="LengthUnit"></a>
152+
## type [LengthUnit](<https://github.com/atomicgo/convert/blob/main/length.go#L4>)
153+
154+
LengthUnit represents a conversion factor to meters.
155+
156+
```go
157+
type LengthUnit float64
158+
```
159+
160+
<a name="Nanometer"></a>Length units define conversion factors for common distance units.
161+
162+
```go
163+
const (
164+
Nanometer LengthUnit = 9.999999999e-10 // Nanometer to meter conversion
165+
Micrometer LengthUnit = 0.000001 // Micrometer to meter conversion
166+
Millimeter LengthUnit = 0.001 // Millimeter to meter conversion
167+
Centimeter LengthUnit = 0.01 // Centimeter to meter conversion
168+
Decimeter LengthUnit = 0.1 // Decimeter to meter conversion
169+
Meter LengthUnit = 1 // Meter is the base unit
170+
Decameter LengthUnit = 10 // Decameter to meter conversion
171+
Hectometer LengthUnit = 100 // Hectometer to meter conversion
172+
Kilometer LengthUnit = 1000 // Kilometer to meter conversion
173+
Megameter LengthUnit = 1000000 // Megameter to meter conversion
174+
Gigameter LengthUnit = 1000000000 // Gigameter to meter conversion
175+
Terameter LengthUnit = 1000000000000 // Terameter to meter conversion
176+
Petameter LengthUnit = 1000000000000000 // Petameter to meter conversion
177+
Exameter LengthUnit = 1000000000000000000 // Exameter to meter
178+
Micron LengthUnit = 0.000001 // Micron to meter conversion
179+
Picometer LengthUnit = 1e-12 // Picometer to meter conversion
180+
Femtometer LengthUnit = 9.999999999e-16 // Femtometer to meter conversion
181+
Attometer LengthUnit = 1e-18 // Attometer to meter conversion
182+
183+
Thou LengthUnit = 2.54e-5 // Thou (mil) to meter conversion
184+
Inch LengthUnit = 0.0254 // Inch to meter conversion
185+
Foot LengthUnit = 0.3048 // Foot to meter conversion
186+
Yard LengthUnit = 0.9144 // Yard to meter conversion
187+
Chain LengthUnit = 20.1168 // Chain to meter conversion (66 feet)
188+
Rope LengthUnit = 6.096 // Rope to meter conversion (20 feet)
189+
Furlong LengthUnit = 201.168 // Furlong to meter conversion (1/8th of a mile)
190+
Mile LengthUnit = 1609.344 // Mile to meter conversion
191+
League LengthUnit = 4828.032 // League to meter conversion (3 miles)
192+
NauticalMile LengthUnit = 1852 // Nautical Mile to meter conversion (international)
193+
194+
AstronomicalUnit LengthUnit = 149597870691 // Astronomical Unit (AU) to meter conversion
195+
LightYear LengthUnit = 9460730472580044 // Light-year to meter conversion
196+
Parsec LengthUnit = 30856775812799588 // Parsec to meter conversion
197+
Megaparsec LengthUnit = 3.085677581e+22 // Megaparsec to meter
198+
Kiloparsec LengthUnit = 30856775812799586000 // Kiloparsec to meter
199+
PlanckLength LengthUnit = 1.616049999e-35 // Planck length to meter conversion
200+
201+
Angstrom LengthUnit = 9.999999999e-11 // Angstrom to meter conversion
202+
Fathom LengthUnit = 1.8288 // Fathom to meter conversion (6 feet)
203+
Rod LengthUnit = 5.0292 // Rod to meter conversion (16.5 feet)
204+
SurveyFoot LengthUnit = 0.3048006096 // Survey foot to meter conversion (used in land surveys)
205+
Pica LengthUnit = 0.0042333333 // Pica to meter conversion (commonly used in typography)
206+
Point LengthUnit = 0.0003527778 // Point to meter conversion (1/12th of a pica)
207+
Hand LengthUnit = 0.1016 // Hand to meter conversion (used in measuring the height of horses)
208+
)
209+
```
210+
161211
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
162212

163213

0 commit comments

Comments
 (0)