Git Product home page Git Product logo

gomove's Introduction

gomove

gomove is a utility to help you move golang packages by automatically changing the import paths from the old one to new one.


Getting Started

Getting started with gomove is really easy. If you have a proper $GOPATH setup and your path set to bin directory in $GOPATH, you can do the following to get gomove tool:

$ go get -u github.com/ksubedi/gomove

You can also download pre-built binary files and debian packages from the releases page.

Once you have the gomove installed, using it is really easy. First, move your package directory to the new directory and run gomove tool.

In this example, we are moving package github.com/ksubedi/go-web-seed to github.com/ksubedi/new-project. First we move the first directory to the second one, then we can do the following to automatically update the imports:

$ gomove -d $GOPATH/src/github.com/ksubedi/new-project github.com/ksubedi/go-web-seed github.com/ksubedi/new-project

You can also cd to the directory of github.com/ksubedi/new-project and run gomove like this:

$ gomove github.com/ksubedi/go-web-seed github.com/ksubedi/new-project

You can also only replace the contents one file only by using -f or --file flag.

$ gomove -f hello.go github.com/bla/bla github.com/foo/bar

You can also run gomove --help for help.

$ gomove --help
NAME:
   gomove - Move Golang packages to a new path.

USAGE:
   gomove [global options] command [command options] [old path] [new path]
   
VERSION:
   0.2.17
   
AUTHOR(S):
   Kaushal Subedi <[email protected]> 
   
COMMANDS:
   help, h	Shows a list of commands or help for one command
   
GLOBAL OPTIONS:
   --dir, -d "./"		directory to scan
   --file, -f 			only move imports in a file
   --safe-mode, -s "false"	run program in safe mode (comments will be wiped)
   --help, -h			show help
   --version, -v		print the version

Safe Mode

By default this tool uses something called native mode where it scans through the go files, finds import statements and replaces the package names. However if you want to use a more safe way of changing the import statements, you can use Safe Mode which parses the ast tree of the go file and replaces imports from there. The biggest downside to using this is that it will prettify your files. To use it in safe mode set the --safe-mode or -s flag to true:

gomove --safe-mode true github.com/bla/bla github.com/foo/bar

License

This software is licensed under the GNU GPL V3 License. Check LICENSE.md for full license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.