goop

command module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 9 Imported by: 0

README

Go Obsolescence Obliteration Program (GOOP)

Go Report Card Documentation GitHub issues license

A tool to automatically modernize your Go code by applying version-specific transformations.

Usage

# Basic usage
goop -dir .

# Exclude directories (supports wildcards)
goop -dir . -exclude-dir mocks/ -ed vendor/ -ed testdata/

# Exclude specific rules (supports wildcards)
goop -dir . -exclude-rule go1.18:* -er go1.21:UseClearBuiltin

# Combine directory and rule exclusions
goop -dir . -ed vendor/ -er go1.22:*
Flags
  • -dir - Directory containing go.mod and Go source files (default: .)
  • -exclude-dir (aliases: -exclude-dirs, -ed) - Path pattern to exclude (can be specified multiple times, supports wildcards)
  • -exclude-rule (aliases: -exclude-rules, -er) - Rule ID pattern to exclude (can be specified multiple times, supports wildcards)
Supported Rules

GOOP automatically applies modernization rules based on your Go version in go.mod.

  • go1.18:AliasEmptyInterface - Replace interface{} with any
  • go1.21:UseClearBuiltin - Replace map/slice clear loops with clear() builtin
    • for k := range m { delete(m, k) }clear(m)
    • for i := range s { s[i] = nil }clear(s)
  • go1.21:UseMinMaxBuiltin - Replace if-else comparisons with min()/max() builtins and remove user-defined min/max functions
    • if a > b { return a } return breturn max(a, b)
    • Removes helper functions: min, max, Min, Max, minimum, Maximum, smallest, Smallest, largest, Largest, biggest, Biggest
    • Handles 2-parameter, 3+-parameter, and variadic implementations
  • go1.21:UseSlicesPackage - Replace manual operations with slices package functions
    • sort.Ints(s)slices.Sort(s)
    • sort.Strings(s)slices.Sort(s)
    • sort.Float64s(s)slices.Sort(s)
  • go1.21:UseMapsPackage - Replace manual operations with maps package functions
    • Manual map cloning → maps.Clone(m)
    • Manual map equality → maps.Equal(m1, m2)
  • go1.21:UseCmpPackage - Replace comparison ladders with cmp package functions
    • Three-way comparison → cmp.Compare(a, b)
    • Zero-coalescing → cmp.Or(a, b)
  • go1.22:RemoveVariableCapture - Remove unnecessary loop variable captures
    • for _, v := range items { v := v; ... }for _, v := range items { ... }
  • go1.23:UseWaitGroupGo - Replace WaitGroup Add/Done pattern with Go() method
    • wg.Add(1); go func() { defer wg.Done(); ... }()wg.Go(func() { ... })

Installation

From Binary Releases

Download the latest release for your platform from the releases page.

macOS (Intel):

curl -L https://github.com/adrianosela/goop/releases/latest/download/goop_v0.0.4_Darwin_x86_64.tar.gz | tar xz
sudo mv goop /usr/local/bin/

macOS (Apple Silicon):

curl -L https://github.com/adrianosela/goop/releases/latest/download/goop_v0.0.4_Darwin_arm64.tar.gz | tar xz
sudo mv goop /usr/local/bin/

Linux (amd64):

curl -L https://github.com/adrianosela/goop/releases/latest/download/goop_v0.0.4_Linux_x86_64.tar.gz | tar xz
sudo mv goop /usr/local/bin/

Linux (arm64):

curl -L https://github.com/adrianosela/goop/releases/latest/download/goop_v0.0.4_Linux_arm64.tar.gz | tar xz
sudo mv goop /usr/local/bin/

Windows: Download the .zip file for your architecture and extract it to a directory in your PATH.

From Source
go install github.com/adrianosela/goop@latest
Supported Platforms

GOOP provides pre-built binaries for:

  • Linux: amd64, arm64, arm (v7)
  • macOS: amd64 (Intel), arm64 (Apple Silicon)
  • Windows: amd64, arm64
  • FreeBSD: amd64, arm64, arm (v7)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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