convert

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 5 Imported by: 0

README

convert — type conversion utilities

import "github.com/downsized-devs/sdk-go/convert"

Stability: Stable — see STABILITY.md

Converts between primitive types, string-case styles, and roman numerals.

Features

  • ToInt64, ToFloat64, ToString, ToArrInt64 — primitive conversion.
  • IntToChar — integer to Excel-style column letter.
  • ToCamelCase, ToPascalCase, PascalCaseToCamelCase.
  • RomanToInt64, Int64ToRoman — roman numerals.

Installation

go get github.com/downsized-devs/sdk-go/convert

Quick Start

n, _ := convert.ToInt64("42")        // 42
s := convert.ToCamelCase("hello_world") // "helloWorld"
r := convert.Int64ToRoman(2026)        // "MMXXVI"

API Reference

Symbol Signature
ToInt64 (any) (int64, error)
ToFloat64 (any) (float64, error)
ToString (any) (string, error)
ToArrInt64 (any) ([]int64, error)
IntToChar (int) string
ToCamelCase / ToPascalCase / PascalCaseToCamelCase (string) string
RomanToInt64 (string) (int64, error)
Int64ToRoman (int64) string

Error Handling

Numeric conversions wrap with codes from codes (parse-error range) via errors.

Dependencies

  • Internal: codes, errors
  • External: github.com/cstockton/go-conv

Testing

go test ./convert/...

Contributing

See CONTRIBUTING.md.

  • null — when conversions might produce SQL nulls.
  • parser — higher-level JSON/CSV parsing.

Documentation

Overview

Package convert offers type-coercion helpers (To/Int64, ToArrInt64, ToFloat64, etc.) backed by reflection and the go-conv library. All helpers return wrapped errors with CodeInvalidValue on failure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int64ToRoman

func Int64ToRoman(num int64) string

func IntToChar

func IntToChar(i int) string

Convert integer to its character representation (eg. 1=A 3=C). Support multiple character for number greater than 26 (eg. 27=AA 703=AAA)

func PascalCaseToCamelCase

func PascalCaseToCamelCase(s string) string

Convert Pascal Case string (PascalCase) to Camel Case string (camelCase)

func RomanToInt64

func RomanToInt64(roman string) int64

func ToArrInt64

func ToArrInt64(i interface{}) ([]int64, error)

func ToCamelCase

func ToCamelCase(input string) string

Convert Text to camel case string with lower case in beginning ex: "Additional Item" --> "additionalItem"

func ToFloat64

func ToFloat64(i interface{}) (float64, error)

func ToInt64

func ToInt64(i interface{}) (int64, error)

func ToPascalCase

func ToPascalCase(input string) string

Convert text to camel case string with upper case in beginning ex: "additional item" --> "AdditionalItem"

func ToString

func ToString(i interface{}) (string, error)

Convert any data to string. This function will always return nil error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL