go-change-ref

command module
v0.0.0-...-9370ab4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 19 Imported by: 0

README

go-change-ref

What is this?

go-change-ref changes all references to specific Go symbols (Type, Function, Variable...) in your project to another. This tool will be especially useful for changing package organization during refactoring.

Install

$ go install github.com/matope/go-change-ref

How to use

After you moved a type definition pkg2.T2 to pkg3.T3, you can change all references to pkg2.T2 to pkg3.T3 with go-change-ref.

Before
package main

import (
	"fmt"

	"github.com/matope/go-change-ref/example/pkg2"
)

func main() {
	var t2 pkg2.T2
	fmt.Println(t2)
}
Run
$ go-change-ref -w \
    -from github.com/matope/go-change-ref/example/pkg2.T2 \
    -to   github.com/matope/go-change-ref/example/pkg3.T3 \
    ./...
After
package main

import (
	"fmt"

	"github.com/matope/go-change-ref/example/pkg3" // UPDATED.
)

func main() {
	var t2 pkg3.T3 // UPDATED.
	fmt.Println(t2)
}
flags
  -from string
        from symbol. importpath.name
  -to string
        to symbol. importpath.name.
  -to-pkg-name string
        package name used when the package name conflits with another imported package
  -w    overwrite .go code

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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