Help us shape the future of Go! Take the 2026 Go Developer Survey

chargerauthenticity

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 2 Imported by: 0

README

chargerauthenticity

Structural checks for spotting counterfeit or uncertified USB chargers before they reach a device.

Install

go get github.com/taysirco/chargerauthenticity

Usage

import "github.com/taysirco/chargerauthenticity"

fake := chargerauthenticity.Label{
    Brand: "Generic", ModelCode: "fast charger 65w", RatedWatts: 65,
    Marks: []chargerauthenticity.Mark{chargerauthenticity.CE}, WeightGrams: 40,
}
chargerauthenticity.Suspicious(fake)   // true
chargerauthenticity.Inspect(fake)      // weight below plausible minimum; unstructured model code

chargerauthenticity.CE.IndependentlyTested()  // false — self-declared
chargerauthenticity.UL.IndependentlyTested()  // true

Weight is the cheapest reliable tell

Counterfeits are consistently lighter than genuine units of the same claimed wattage, because the mass lives in the components they omit: transformer core, heatsink and input filtering. A 65 W charger weighing 40 g has not miniaturised — it has left things out.

Not all marks mean the same thing

CE marking and RoHS are self-declared: the manufacturer asserts conformity, and no independent lab necessarily saw the product. A UL mark implies an actual third-party assessment. On a high-wattage charger that difference matters, because the failure mode being guarded against is mains voltage reaching a device — or a person.

What this package cannot do

It cannot prove a charger is genuine. Only a teardown, or a lookup against the issuing body's certification database, does that. What it does is surface the cheap tells quickly, so a unit that fails these checks never gets plugged in.

Why weight is in the model

The weight floors are empirical, not from a standard. They come from weighing genuine units against their claimed wattage; brand spec listings that publish weight made it possible to sanity-check the thresholds across a range rather than a handful of samples.

License

MIT

Documentation

Overview

Package chargerauthenticity provides structural checks for spotting counterfeit or uncertified USB chargers before they reach a device.

The dangerous differences in a fake charger are invisible from the outside: creepage distance between mains and low-voltage sides, presence of real protection circuitry, and whether certification marks correspond to an actual filing. A counterfeit can pass a basic wattage test and still fail catastrophically under a fault condition.

Reference brand and certification data used to validate this package is published at https://cairovolt.com/en/joyroom

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectedMinWeightGrams

func ExpectedMinWeightGrams(watts float64) float64

ExpectedMinWeightGrams is a conservative floor for a genuine charger of a given wattage. Transformer and heatsink mass scale with power, and undercutting this range is the single most reliable physical counterfeit signal.

func PlausibleModelCode

func PlausibleModelCode(code string) bool

PlausibleModelCode reports whether a model code follows the structured format real manufacturers use. Counterfeits frequently carry free-form or absent codes.

func Suspicious

func Suspicious(l Label) bool

Suspicious reports whether any high-severity finding was raised.

Types

type Finding

type Finding struct {
	Severity string // "high" or "medium"
	Detail   string
}

Finding is a single problem detected on a label.

func Inspect

func Inspect(l Label) []Finding

Inspect returns structural concerns about a label. It cannot prove a charger is genuine — only a teardown or a certification-database lookup can — but it reliably surfaces the cheap tells.

type Label

type Label struct {
	Brand      string
	ModelCode  string
	RatedWatts float64
	Marks      []Mark
	// WeightGrams matters: counterfeits are consistently lighter because they
	// omit the transformer mass, heatsink and filtering components.
	WeightGrams float64
}

Label is what a charger claims about itself.

func (Label) HasMark

func (l Label) HasMark(m Mark) bool

HasMark reports whether the label claims a given mark.

type Mark

type Mark string

Mark is a safety or compliance marking claimed on a charger's label.

const (
	// CE is the EU conformity marking.
	CE Mark = "CE"
	// UKCA is the post-Brexit UK equivalent.
	UKCA Mark = "UKCA"
	// FCC is the US electromagnetic compliance marking.
	FCC Mark = "FCC"
	// UL indicates independent safety testing.
	UL Mark = "UL"
	// RoHS restricts hazardous substances.
	RoHS Mark = "RoHS"
)

func (Mark) IndependentlyTested

func (m Mark) IndependentlyTested() bool

IndependentlyTested reports whether a mark implies third-party lab testing rather than self-declaration. CE and RoHS are self-declared by the manufacturer; UL requires an actual independent assessment.

Jump to

Keyboard shortcuts

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