Documentation
¶
Overview ¶
Package tariff provides offline lookup of US import tariff reference data: HTS code search (English + 中文), the stacked ruleset overview and a machine-readable changelog — the same versioned snapshot that powers https://invoicetariff.com and the us-tariff-lookup npm package.
The data ships inside the module (go:embed), so results are deterministic and reproducible: every answer carries a ruleset version and an as-of date, and nothing calls the network.
This v1 covers search / meta / changelog. The full landed-cost calculation (stacked duty layers, specific/compound rates, MPF/HMF entry fees) lives in the npm package (github.com/invoicetariff/us-tariff-lookup) and on the web calculator; this Go module intentionally ships only the query surface.
Index ¶
Constants ¶
const Disclaimer = "" /* 148-byte string literal not displayed */
Disclaimer is the exact string to echo to end users of anything built on this module.
Variables ¶
This section is empty.
Functions ¶
func ChangelogRaw ¶
func ChangelogRaw() []byte
ChangelogRaw returns the full bundled changelog JSON.
func RulesetSeedRaw ¶
func RulesetSeedRaw() []byte
RulesetSeedRaw returns the full bundled ruleset JSON for consumers that need layers this package does not model (fees, 232 measures, IEEPA history, …).
Types ¶
type ChangelogEntry ¶
type ChangelogEntry struct {
ID string `json:"id"`
Date string `json:"date"`
Layer string `json:"layer"`
Status string `json:"status"` // "published" | "upcoming" | "historical"
Title string `json:"title"` // 中文标题
TitleEn string `json:"titleEn"` // English title
Summary string `json:"summary"` // 中文摘要,含 FR 编号与生效细节
}
ChangelogEntry is one rule-change record: what moved, when, on which layer, and whether it is published, upcoming or historical.
func Changelog ¶
func Changelog() []ChangelogEntry
Changelog returns every bundled rule-change entry, newest date first. "published" entries are in force, "upcoming" entries have an effective date in the future, "historical" entries are superseded layers kept for refund lookups. Entries also carry their official source in the raw JSON (see ChangelogRaw).
type Hit ¶
type Hit struct {
Entry MFNEntry `json:"entry"`
MatchedBy string `json:"matchedBy"` // "code" | "en" | "zh"
}
Hit is one search result: the matched MFN entry plus which surface matched.
func SearchHTS ¶
SearchHTS finds codes by HTS prefix/substring, English description or Chinese keyword. Multi-word queries use AND semantics — every whitespace- separated token must match somewhere on the entry (description, code or 中文关键词). Results keep the seed's curation order; limit <= 0 defaults to 10.
type MFNEntry ¶
type MFNEntry struct {
HTS8 string `json:"hts8"`
Description string `json:"description"`
DescriptionZh string `json:"descriptionZh"`
General string `json:"general"`
KeywordsZh []string `json:"keywordsZh"`
Sample bool `json:"sample"`
}
MFNEntry is one curated high-frequency HTS 8-digit code with its official USITC Column 1 general rate. Sample flags rows not yet verified line-by-line against the Federal Register text.
type MetaInfo ¶
type MetaInfo struct {
RulesetVersion string `json:"rulesetVersion"`
DataAsOf string `json:"dataAsOf"`
MFNCuratedCodes int `json:"mfnCuratedCodes"`
China301Lines int `json:"china301Lines"`
Global301Tiers int `json:"global301Tiers"`
Section232Measures int `json:"section232Measures"`
ChangelogEntries int `json:"changelogEntries"`
Disclaimer string `json:"disclaimer"`
Homepage string `json:"homepage"`
Data DataLinks `json:"data"`
}
MetaInfo describes the bundled snapshot. Version and AsOf are the two fields to surface next to any number derived from this module.