ident

package
v0.0.0-...-1dd84ce Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ident turns arbitrary CSV headers and JSON keys into safe SQL identifiers: snake_case where possible, quoted where necessary, unique within a table, and never colliding with a reserved word unquoted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dedupe

func Dedupe(names []string) []string

Dedupe makes every name unique in order, appending _2, _3, … to later duplicates. The first occurrence keeps its bare name.

func NeedsQuote

func NeedsQuote(name string) bool

NeedsQuote reports whether an identifier must be double-quoted: anything that is not a bare ASCII snake_case word, or that is a reserved word.

func Quote

func Quote(name string) string

Quote renders an identifier for SQL, double-quoting only when required. Double-quote quoting with `""` escaping is shared by Postgres, SQLite and DuckDB, so one implementation serves all three dialects.

func Sanitize

func Sanitize(source string, index int) string

Sanitize converts one source name into an identifier candidate: lowercased, punctuation collapsed to single underscores, Unicode letters preserved (they are legal in all three dialects when quoted). index is the zero-based column position, used for the fallback name.

func TableName

func TableName(path string) string

TableName derives a table name from a file path: the base name without its extension, sanitized. Empty or unusable input falls back to "data" (the stdin case).

Types

This section is empty.

Jump to

Keyboard shortcuts

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