Help us shape the future of Go! Take the 2026 Go Developer Survey

gorep

command module
v0.0.0-...-96a7001 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2016 License: MIT Imports: 7 Imported by: 0

README

gorep

Simple tools to replace imported package name in golang project. Useful to manage a project which deployed into multiple application on one server.

Please continue reading, you'll understand what is the purpose of this library

Story

This package is only useful when:

  1. You are not using golang vendor
  2. Your project is deployed as multiple app in one server

Say that you have a project which the package path is github.com/novalagung/project. This project deployed to server as 3 different environment (one for testing, one for dev, one for production).

screen shot 2016-09-26 at 10 03 12 pm

When you want to build the project-dev and project-test, you have to change imported package names in all files inside each folder.

import "github.com/novalagung/project/model"
import "github.com/novalagung/project/controller"
import "github.com/novalagung/project/conf"
import "github.com/novalagung/project/view"
// ... and so oon, in all files

need to be replaced into this for the project-dev, as well as project-test

import "github.com/novalagung/project-dev/model"
import "github.com/novalagung/project-dev/controller"
import "github.com/novalagung/project-dev/conf"
import "github.com/novalagung/project-dev/view"

It'll waste your time so much, espesially if there are tons of file inside. TONS!. This simple library could be your life-saver.

Installation

go get github.com/novalagung/gorep

Make sure $GOPATH/bin is added to your $PATH variable.

Usage

Go to your project folder, then run this

cd $GOPATH/src/github.com/novalagung/project-dev
gorep -from="github.com/novalagung/project" \ 
      -to="github.com/novalagung/project-dev"

Or use flag -path to specify the project location

gorep -path="/User/novalagung/goapp/src/github.com/novalagung/project-dev" \
      -from="github.com/novalagung/project" \
      -to="github.com/novalagung/project-dev"

All files which contains github.com/novalagung/project inside those choosen folder will be replaced with github.com/novalagung/project-dev.

  • Flag -from filled with package name you want to replace
  • Flag -to is the new name
  • Flag -path (optional) is the project path you want to hack. By default it'll be current active directory

Author

Noval Agung Prayogo

License

MIT

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