Manage dependencies and build Go projects outside GOPATH
This repository has been archived on 2019-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Lunny Xiao df11fdc044
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
lunny/gop_release (#35)
2019-08-27 06:37:58 +00:00
.circleci fix circleci config and README 2017-08-21 13:42:00 +08:00
cmd fix conflict with go mod (#32) 2019-08-27 05:27:30 +00:00
examples update example 2019-08-14 11:06:21 +08:00
vendor update example 2019-08-14 11:06:21 +08:00
.drone.yml lunny/gop_release (#35) 2019-08-27 06:37:58 +00:00
.gitignore update example 2019-08-14 11:06:21 +08:00
doc.go use go mod 2019-05-18 18:16:34 +08:00
Dockerfile add Dockerfile 2019-08-20 11:06:52 +08:00
go.mod update example 2019-08-14 11:06:21 +08:00
go.sum update example 2019-08-14 11:06:21 +08:00
LICENSE add LICENSE file 2017-08-17 13:30:40 +08:00
main.go lunny/gop_release (#35) 2019-08-27 06:37:58 +00:00 use go mod 2019-05-18 18:16:34 +08:00 use go mod 2019-05-18 18:16:34 +08:00



Build Status

GOP is a project manangement tool for building your golang applications out of global GOPATH. In fact gop will keep both global GOPATH and every project GOPATH. But that means your project will not go-getable. Of course, GOP itself is go-getable. GOP copy all denpendencies from global GOPATH to your project's src/vendor directory and all application's sources are also in src directory.

A normal process using gop is below:

git clone
cd aaa
gop ensure -g
gop build
gop test


  • GOPATH compitable
  • Multiple build targets support
  • Put your projects out of global GOPATH


Please ensure you have installed the go command, GOP will invoke it on building or testing

go get

Directory structure

Every project should have a GOPATH directory structure and put a gop.yml int the root directory. This is an example project's directory tree.

<project root>
├── gop.yml
├── bin
├── doc
└── src
    ├── main
    │   └── main.go
    ├── models
    │   └── models.go
    ├── routes
    │   └── routes.go
    └── vendor
            ├── go-xorm
            │   ├── builder
            │   ├── core
            │   └── xorm
            └── lunny
                ├── log
                └── tango


Gop will recognize a gop project which has gop.yml. The file is also a project configuration file. Below is an example. If you didn't define any target, the default target is src/main and the target name is the project name.

- name: myproject1
  dir: main
  - templates
  - public
  - config.ini
  - key.pem
  - cert.pem
- name: myproject2
  dir: web
  - templates
  - public
  - config.ini
  - config.ini



Create the default directory structure tree.

mkdir newproject
cd newproject
gop init

and you can also create config file for vscode

gop init -e=vscode


Automatically copy dependencies from $GOPATH to local project directory. -g will let you automatically call go get <package> when the package is missing on GOPATH. -u will always go get <package> on all the dependencies and copy them to vendor.

gop ensure [-g|-u] [target_name]


List all dependencies of this project and show the status.

gop status [target_name]


Add one or more packages to this project.

gop add <package1> <package2>


Update one or more packages to this project. All missing dependent packages will also be added. -f will update exists dependent packages.

gop update [-f] <package1> <package2>


Remove one or more packages from this project.

gop rm <package1> <package2>


Run go build on the src directory. If you want to execute ensure before build, you can use -e flag.

gop build [-e] [target_name]


Run go run on the src directory. -w will monitor the go source code changes and automatically build and run again. -e will automatically execute ensure before every time build.

gop run [-w] [target_name]


Run go test on the src directory. If you want to execute ensure before build, you can use -e flag.

gop test [-e] [target_name]


Run go release on the src directory.

gop release [target_name]


  • Versions support, specify a dependency package verison
  • Support run gop in GOPATH