xmocks

command
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 14 Imported by: 0

README

xmocks

xmocks is a small CLI generator for creating package mocks in the style of internal/pkgxmock/xfs.go.

Purpose

This tool parses a Go source file, extracts a named interface, and emits a mocked implementation that follows the existing xfs mock conventions:

  • TestCase<Alias>
  • NewMock<Alias>
  • Mock<Alias>
  • mockOnCall<Alias>
  • mockSetReturn<Alias>

The generated file is created under internal/pkgxmock/<alias>.go by default, or at a path passed by the developer.

Usage

go run ./xmocks --file=<path/to/source.go> --interface=<InterfaceName> [--alias=<Alias>] [--output=<dir|path>]
Required flags
  • --file — path to the Go source file containing the interface
  • --interface — name of the interface to mock
Optional flags
  • --alias — alias used in generated mock type names; defaults to the interface name
  • --output — output directory or file path for generated mock; defaults to internal/pkgxmock/<alias>.go

Example

go run ./xmocks --file=xfs/pkgbridge.go --interface=IPkgBridgeXFS --alias=XFS

This generates:

internal/pkgxmock/xfs.go

or, if --output is provided with a directory:

go run ./xmocks --file=xfs/pkgbridge.go --interface=IPkgBridgeXFS --alias=XFS --output=tmp/test

This generates:

tmp/test/xfs.go

Testing

To run the package tests:

go test ./xmocks

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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