The fastest path to a working setup: install the core module and the Lucide submodule, write three lines of Go, and start rendering icons.
What it does
The lucide submodule provides the Lucide icon set (~1,500 icons) embedded directly in the Go binary via go:embed. No file downloads, no network calls, no external dependencies beyond the core module.
When to use it
Reach for the embedded Lucide set as the default icon source for projects that need a general-purpose icon set with zero runtime setup.
For custom icon sets on disk, see Directory Provider. For other Iconify-format JSON sets, see JSON Collection Provider. For on-demand access to any Iconify-hosted set, see Iconify Provider.
Setup
Quick start with Default()
import ( swarmicons "github.com/frostybee/go-swarm-icons" "github.com/frostybee/go-swarm-icons/lucide")manager := swarmicons.Default("lucide", lucide.Provider())This registers the Lucide set under the "lucide" prefix and sets it as the default prefix. Bare icon names (without a colon) resolve against it:
icon, err := manager.Get("home") // resolves as "lucide:home"icon, err = manager.Get("lucide:star") // explicit prefixConfig builder
import ( swarmicons "github.com/frostybee/go-swarm-icons" "github.com/frostybee/go-swarm-icons/lucide")manager, err := swarmicons.NewConfig(). AddProvider("lucide", lucide.Provider()). DefaultPrefix("lucide"). DefaultAttributes(map[string]string{ "stroke": "currentColor", "stroke-width": "2", "fill": "none", }). Build()Options & behavior
Return type
lucide.Provider() returns *swarmicons.JsonCollectionProvider, not the Provider interface directly. It satisfies the Provider interface and can be passed anywhere a Provider is expected.
Embedded data
The submodule uses go:embed lucide.json to bundle the Iconify JSON collection. The embedded file is approximately 800 KB and adds that amount to the compiled binary size.
Inherited behavior
Because lucide.Provider() returns a JsonCollectionProvider, it inherits all of that provider's behavior:
- Lazy parsing: the embedded JSON is parsed on the first call to
Get(),Has(), orAll(). - Alias resolution: Lucide aliases (if any exist in the JSON) resolve recursively up to 10 levels.
- Caching: resolved icons are cached in a thread-safe in-memory map.
- Root-level defaults: the embedded JSON specifies
width: 24andheight: 24as defaults.
Icon count
All() returns more than 1,000 icon names. The exact count depends on the version of the embedded Lucide JSON.
Installation
The Lucide submodule is a separate Go module. Install it alongside the core module:
go get github.com/frostybee/go-swarm-icons@latestgo get github.com/frostybee/go-swarm-icons/lucide@latestExamples
Render an icon
import ( "fmt" swarmicons "github.com/frostybee/go-swarm-icons" "github.com/frostybee/go-swarm-icons/lucide")func main() { manager := swarmicons.Default("lucide", lucide.Provider()) icon, err := manager.Get("rocket") if err != nil { panic(err) } fmt.Println(icon.Size(24).Class("text-primary").ToHTML())}Alongside other providers
import ( "fmt" "log" swarmicons "github.com/frostybee/go-swarm-icons" "github.com/frostybee/go-swarm-icons/lucide")func main() { manager, err := swarmicons.NewConfig(). AddProvider("lucide", lucide.Provider()). AddIconifySet("mdi"). AddDirectory("custom", "./icons"). DefaultPrefix("lucide"). Build() if err != nil { log.Fatal(err) } // Lucide icon (default prefix) home, _ := manager.Get("home") fmt.Println(home.ToHTML()) // Material Design icon (explicit prefix) mdiHome, _ := manager.Get("mdi:home") fmt.Println(mdiHome.ToHTML()) // Custom icon from disk logo, _ := manager.Get("custom:logo") fmt.Println(logo.ToHTML())}Choosing a provider
| Provider | Source | Network | Disk | Caching | Best for |
|---|---|---|---|---|---|
| Directory | .svg files |
No | Yes | Per-icon on first access | Custom/brand icons |
| JSON Collection | Iconify JSON | No | Yes (or go:embed) |
Full parse on first call | Production icon sets |
| Iconify API | HTTP API | Yes | No | Per-icon on first fetch | Prototyping, unknown sets |
| Chain | Multiple providers | Depends | Depends | Per-provider | Local-first + fallback |
| Embedded Lucide | go:embed in binary |
No | No | Full parse on first call | Quick start, Lucide-only |
See also
- Providers API reference: full
JsonCollectionProviderAPI (whichlucide.Provider()returns) - JSON Collection Provider: load other Iconify sets beyond Lucide
- Quick Start: the fastest path using this submodule