mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 12:00:39 +00:00
8c7017a99d
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
1.6 KiB
1.6 KiB
obiutils Package — Semantic Feature Summary
This Go package provides a set of utility functions for type conversion, casting validation, and map/slice transformation in a flexible, error-tolerant manner.
InterfaceToString(i interface{}): Converts any value to a string, preferring theStringerinterface if implemented.CastableToInt(i interface{}): Checks whether a value is numerically castable to anint(supports all numeric types).InterfaceToBool(i interface{}): Safely converts various input types (bool, numeric, string like"true","1", etc.) tobool; returns a custom error for unsupported types.InterfaceToInt(i interface{}): Converts numeric or string representations to anint, with precise error handling.InterfaceToFloat64(i interface{}): Converts numeric or string types tofloat64, using standard parsing.MapToMapInterface(m interface{}): Converts specialized map types (e.g., read-only or concurrency-safe maps) tomap[string]interface{}via reflection.InterfaceToIntMap(i interface{}): Converts compatible map types (map[string]int,hasMapinterfaces, or generic maps) to a concretemap[string]int.InterfaceToStringMap(i interface{}): Converts map values to strings, yielding a cleanmap[string]string.InterfaceToStringSlice(i interface{}): Converts slices of interfaces or strings into a pure[]string.
All functions include explicit error handling via custom types (e.g., NotAnInteger, NotAMapInt) and use logging via Logrus for debugging. The package prioritizes type safety, robustness, and interoperability across Go types.