VS Code Extensions
Golang Enum Generator

Golang Enum Generator

by Jennsen

Generates Golang iota enums from filenames with multiple cases

Downloads

21

Rating

5.0 / 5 (1)

Version

1.0.2

Last updated

Apr 15, 2026

A professional VS Code extension to automate the generation of Golang enums using the iota pattern. It handles construction, string conversion, and provides lookup method.

Features

  • Generate Enum: Create a full enum structure from scratch. Automatically detects package and determines the type name from the filename.
  • Add Cases: Add new cases to an existing enum at any time. It merges existing cases with new ones.
  • Remove Cases: Easily remove one or more cases from an existing enum.

Commands

Command Description
Golang Enum Generator: Generate Generates a new enum or replaces an existing one with new cases.
Golang Enum Generator: Add Appends new cases to an existing enum.
Golang Enum Generator: Remove Removes specified cases from an existing enum.

Usage

  1. Open or create a .go file (e.g., user_role.go).
  2. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
  3. Search for one of the Golang Enum Generator commands.
  4. Follow the prompts to enter case names (comma-separated).

Example Output

package vo

import "strings"

type DeviceStatus int

const (
	DeviceStatusUnknown DeviceStatus = iota
	DeviceStatusActivated
	DeviceStatusDeactivated

	DeviceStatusUnknownValue = "UNKNOWN"
	DeviceStatusActivatedValue = "ACTIVATED"
	DeviceStatusDeactivatedValue = "DEACTIVATED"
)

func NewDeviceStatusFromString(value string) DeviceStatus {
	v := strings.ToUpper(strings.TrimSpace(value))
	switch v {
	case DeviceStatusUnknownValue:
		return DeviceStatusUnknown
	case DeviceStatusActivatedValue:
		return DeviceStatusActivated
	case DeviceStatusDeactivatedValue:
		return DeviceStatusDeactivated
	default:
		return DeviceStatusUnknown
	}
}

func (e DeviceStatus) Value() string {
	return [...]string{
		DeviceStatusUnknownValue,
		DeviceStatusActivatedValue,
		DeviceStatusDeactivatedValue,
	}[e]
}

Requirements

  • VS Code version 1.80.0 or higher.
  • A Go environment for formatting (recommended).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related extensions