gomv

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 20 Imported by: 0

README

gomv

gomv moves function from one package to another. After moving to another package, the referenced function calls are updated. Before applying changes, a diff preview is also shown.

Currently, it works only for function and does not ensure code will compile successfully after applying changes.

Usage

Move function from one package to another.
Usage:
    gomv [flags] <PackageName.FunctionName> <DestFilePath>

Flags:
    -dir <location of the project directory>
    -no-preview
Installation
go install github.com/nhAnik/gomv/cmd/gomv@latest
Example
gomv -dir <DirectoryName> <PackageName.FunctionName> <DestFilePath>

Here, DestFilePath denotes the path of the destination file. It can be either absolute path or path relative to project root directory.

For example, to move a function named fun inside util package to another file foo/bar.go

gomv -dir /path/to/go/project util.fun foo/bar.go

In /path/to/go/project directory, the -dir flag can be omitted like below:

gomv util.fun foo/bar.go

By default, a preview will be shown before applying changes and users will be prompted whether they want to apply the changes.

To disable preview and blindly accept changes (which is not recommended), -no-preview flag can be used.

gomv -dir /path/to/go/project -no-preview util.fun foo/bar.go

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNo = errors.New("no from user")

Functions

func MoveFunc

func MoveFunc(pkgs []*packages.Package, funcName, srcPkgName, dstFileName string, showPreview bool) error

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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