classify

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package classify maps a Go import path to an architectural layer (controller / service / repository / other) and a best-effort module name, using folder- and naming-convention heuristics.

It is intentionally convention-driven so it works across modular-MVC and hexagonal layouts without per-project annotation. A Config can extend the keyword sets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Classifier

type Classifier struct {
	// contains filtered or unexported fields
}

Classifier classifies import paths into (layer, module).

func New

func New(cfg *Config) *Classifier

New builds a Classifier from the default keyword sets plus any config extras.

func (*Classifier) Classify

func (c *Classifier) Classify(pkgPath string) (layer, module string)

Classify returns the layer and module for an import path. Layer falls back to graph.LayerOther when nothing matches; module is "" when undeterminable.

The module is the bounded-context name. For feature-first layouts (user/service) it is the segment before the layer keyword; for layer-first layouts (core/user, interface/user, handlers/user) it is the segment after.

type Config

type Config struct {
	// Extra maps a canonical layer (graph.LayerController/Service/Repository)
	// to additional keywords to recognize.
	Extra map[string][]string
}

Config allows extending the default keyword sets (optional override).

Jump to

Keyboard shortcuts

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