{"modulePath":"github.com/IPGeolocation/cli/v2","version":"v2.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Constants\n\n```go\nconst ArraySeparator = \"|\"\n```\nArraySeparator joins the elements of an array of scalars inside a single CSV cell.\n\n## Variables\n\n```go\nvar MaxResponseMB int64 = 256\n```\n\n```go\nvar RequestTimeout = 5 * time.Minute\n```\n\n## Functions\n\n```go\nfunc ConvertToCSV(body []byte) (string, error)\n```\nConvertToCSV renders a JSON API response as CSV text.\n\nA top-level JSON array becomes one row per element, which is what the bulk endpoints return; any other response becomes a single row. Nested objects are flattened into dotted column names (\"location.city\"). An array whose elements are all scalars is joined into one cell with ArraySeparator; an array holding objects keeps a column per element instead (\"routes.0.prefix\"), so its fields stay addressable. Columns are the union of the keys of every row, sorted, so the same response always produces the same file.\n\n```go\nfunc ConvertToXML(data interface{}) string\n```\n\n```go\nfunc DecryptString(cipherText string) (string, error)\n```\n\n```go\nfunc EncryptString(plain string) (string, error)\n```\n\n```go\nfunc Get(apiURL string) ([]byte, error)\n```\n\n```go\nfunc OutputFilePath(name, extension string) string\n```\nOutputFilePath works out the file an --output-file value should write to. The extension is appended only when the name does not already end in it, so \"results\" and \"results.csv\" both save to results.csv and neither doubles up.\n\nAn extension that does not match is left in place rather than swapped, so --output-file results.json with --output csv writes results.json.csv. That keeps the name the caller gave and never silently retargets a different file. The comparison ignores case, so results.CSV is accepted as it stands.\n\n```go\nfunc PostJSON(apiURL string, payload interface{}, headers map[string]string) ([]byte, error)\n```\n\n```go\nfunc PrintAsTable(data interface{}, indent int)\n```\n\n```go\nfunc ToTitle(s string) string\n```\n\n```go\nfunc ValidateRequestLimits() error\n```\n\n","path":"github.com/IPGeolocation/cli/v2/internal/utils","name":"utils","synopsis":"","isRedistributable":true}
