Skip to content
Gx
GitHub

GX5001: gx.Enum misses a constant of its type

A gx.Enum map has no entry for one constant of its type.

Cause

A gx.Enum map has no entry for one constant of its type. A value with no entry gives an element with no classes.

Example

ui/button/styles.go
package button

import "github.com/alternayte/gx"

// Variant is the visual style of a button.
type Variant string

const (
	Primary Variant = "primary"
	Ghost   Variant = "ghost"
)

var variantClass = gx.Enum[Variant]{
	Primary: "bg-primary text-primary-foreground",
}

gx lint reports:

gx lint
ui/button/styles.go:13:20: GX5001: gx.Enum misses "Ghost"; every constant of the type needs an entry

Fix

Add an entry for the constant that the message names.