mirror of
https://github.com/rwinkhart/convertroman.git
synced 2026-08-28 21:06:33 -04:00
31 lines
538 B
Markdown
31 lines
538 B
Markdown
# Go Roman Numerals
|
|
|
|
[](https://pkg.go.dev/github.com/brandenc40/romannumeral)
|
|
|
|
Convert to and from roman numerals in Go.
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/brandenc40/romannumeral"
|
|
)
|
|
|
|
func ExampleToInt() {
|
|
integer, err := romannumeral.ToInt("IV")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(integer == 4)
|
|
}
|
|
|
|
func ExampleFromInt() {
|
|
roman, err := romannumeral.FromInt(4)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(roman == "IV")
|
|
}
|
|
```
|