Golang 开发工具,支持项目自启动、实时重载(测试 + 应用程序)和基于 Go 模块的自动依赖获取
GoDevGoDev is a live-reload development tool with first class support for Golang development.
Looking for the old Makefile version? You can find it here
You will require Go > 1.11.x for GoDev to work out of the box because of its usage of go mod.
All releases will also include binaries for all three supported packages with source code so you can build it yourself. See the section on Compilation for details.
For all platforms, simply run the following to install GoDev:
go get github.com/zephinzer/godevInstallation via platform-specific package managers coming soon!
For all the commands below on usage, you may also view them through the help subcommand:
godev helpOr to check your version for bug reports or functionalities:
godev versionRunning godev without flags is the easiest way to get started with live-reload-enabled development:
godevGoDev runs
go mod vendorto install dependencies,go build -o bin/appto build your application, and lastly it runs your app throughbin/app. You might have to runchmod +x bin/appon the first build.
To run the tests, simply specify the test sub-command.
godev testTo view verbose logs, append the --vv flag.
godev test --vvTo initialise a directory for development in the Golang language with Go Modules for package management, use the init sub-command.
godev initIf you'd like to preview files before you install them, you can use the
viewsub-command to check out the file first.
GoDev is also available as a Docker image at zephinzer/godev:latest. To get started using the Docker image, run:
# create the cache directory because volume definitions
# will cause a directory to be created as `root` which
# you will have trouble deleting on the host
mkdir -p ./.cache/pkg;
# instantiate the docker image into a container
docker run -it \
-u $(id -u) \
-v "$(pwd):/go/src/app" \
-v "$(pwd)/.cache/pkg:/go/pkg" \
zephinzer/godev:latest \
godev ...
# ^ add any other flags you want after godev
While GoDev was written focused on Golang development happiness, it can also be used for projects in other languages. Use the configuration flags to adjust it to your needs.
godevWhen run alone, GoDev defaults to running in development mode which means it will run the application in live-reload with automatic dependency retrievals based on your code.
By default, GoDev will run for live-reload in development. This results in the default execution groups of:
go mod vendorgo build -o ${BUILD_OUTPUT} (see --output)${BUILD_OUTPUT}godev Flags| Flag | Description |
|---|---|
--args |
Specifies arguments to pass into commands of the final execution group (the application being live-reloaded) |
--dir |
Specifies the working directory |
--env |
Specifies an environment variable |
--exec |
Specifies comma-delimited commands |
--exec-delim |
Changes the delimiter for the -exec flag |
--exts |
Specifies extensions to watch |
--ignore |
Specifies file/directory names to ignore |
--output |
Specifies the path relative to the working directory where the binary will be put |
--rate |
Specifies the batching duration for file system events |
--silent |
Turns off logging |
--vv |
Turns on verbose logging |
--vvv |
Turns on very verbose logging |
--watch |
Specifies the directory to watch |
testTells GoDev to run in test mode. This changes the default execution groups so that the following are run instead:
go mod vendorgo build -o ${BUILD_OUTPUT} (see --output)go test ./... -coverprofile c.outtest Flags| Flag | Description |
|---|---|
--dir |
Specifies the working directory |
--env |
Specifies an environment variable |
--exts |
Specifies extensions to watch |
--ignore |
Specifies file/directory names to ignore |
--output |
Specifies the path relative to the working directory where the binary will be put |
--rate |
Specifies the batching duration for file system events |
--silent |
Turns off logging |
--vv |
Turns on verbose logging |
--vvv |
Turns on very verbose logging |
--watch |
Specifies the directory to watch |
initSpecifying this sub-command triggers a directory initialisation flow which asks if you would like to initialise some files/directories if they are not found. These are:
init Flags| Flag | Description |
|---|---|
--dir |
Specifies the working directory |
viewSpecifying this flag with the name of a file prints the file to your terminal. For example, godev view main.go will print the main.go file which init will seed for you if you say yes.
view FlagsNone.
helpDisplays the help page.
versionDisplays the version of GoDev
version Flags| Flag | Description |
|---|---|
--commit |
Indiciates to only display the commit hash |
--semver |
Indiciates to only display the semver version |
--vvDefines verbose logs (debug level). Useful for debugging or if you'd like some insights into what triggered your job and to debug the pipeline for your specified execution groups.
--vvvDefines very verbose logs (trace level). More useful if you're developing GoDev itself to trace the flow of events.
--silentTells GoDev to keep completely quiet. Only panic level logs are printed before GoDev exits with a non-zero status code.
--argsSpecifies the arguments to be passed into the last execution group which should contain the path to your binary.
Default: None
--dirSpecifies the directory for commands from GoDev to run from.
Default: Current working directory
--watchSpecifies the directory for GoDev to watch for changes recursively in.
Default: Current working directory
--envSpecifies an environment variable to be passed into commands.
Use multiple of these to specify multiple environment variables.
Usage: godev --env ENV=production --env HTTP_PROXY=http://localhost:1111
--execSpecifies a single execution group. Commands specified in an execution group run in parallel.
Use multiple of these to define multiple execution groups. The execution groups run in sequence themselves.
--exec-delimSpecifies the delimiter used in the --exec flag for separating commands. This flag finds its use if the command you wish to run contains a command as an argument.
Default: ,
--extsDefines a comma separated list of extensions (without the dot) to trigger a file system change event.
Default: go,Makefile
--ignoreDefines names of files/directories to ignore.
Default: bin,vendor
--outputDefines the path to the built output
Default: bin/app
--rateDefines the rate at which file system change events are batched. Modifying this would be useful if you find that commands being run in your execution groups take longer than 2 seconds and modify files resulting in a never-ending file system change trigger loop.
Default: 2s
Start a PR - Before starting on an issue, indicate you're working on it by submitting a PR (either from your own fork, or from a branch of this repository - doesn't matter) with documentation changes. Please also write about what changes you'll be making and analyses of dependencies you're adding (if any).
Pass the automated checks - There's a Travis pipeline check that is mandatory before merges will be allowed.
Squash and merge - This keeps the commit history clean
(For collaborators) - Versioning - On merging, if the PR is related to non-breaking functionality optimisations/additions, do nothing. If it adds something new, consider bumping the minor release if it might change some users' workflows. If it breaks something that people are using, bump the major version.
Run the following to clone this repository:
git clone [email protected]:zephinzer/godev.git;Then copy the sample.properties into Makefile.properties:
cp sample.properties Makefile.properties;Dependencies are stored in the ./vendor directory. Run the following to populate the dependencies:
make depsFor static files that GoDev can initialise, a Go generator is used. The files can be found at ./data/generate and the code to generate the file at ./data.go can be found at ./data/generate.go. The ./data.go is generated with every build, but if you want to generate it manually, run:
make generateDevelopment is done in the ./dev directory. Unfortunately, since this is a live-reload tool, there is no live-reload for the live-reload, so we have to re-run the application every time we make changes for them to be visible. The command to re-compile and re-run GoDev while working with ./dev is:
make startTo run the tests in watch mode:
make testFor running the tests one-off (CI mode):
make test.ciWe try to follow semver versioning as far as possible. This means:
To get the current version:
make version.getTo bump the version:
# bump the patch version
make version.bump
# bump the minor version
make version.bump VERSION=minor
# bump the major version
make version.bump VERSION=majorTo compile GoDev simply run make:
make
# or if you'd like to be specific:
make godevTo build the GoDev image, run:
make dockerWe use two tools for continuous integration: Travis (the CI pipeline runner), and CodeClimate (static code analysis).
The pipeline primarily does the following:
The following are variables that need to be defined for your pipeline:
CC_TEST_REPORTER_ID: Code ClimateDOCKER_IMAGE_REGISTRY: Hostname of the Docker registry we are pushing toDOCKER_IMAGE_NAMESPACE: Namespace of the Docker image (docker.io/THIS/image:tag)DOCKER_IMAGE_NAME: Name of the Docker image (docker.io/namespace/THIS:tagDOCKER_REGISTRY_USERNAME: Username for the Docker registry (when not specified, does not release to DockerHub)DOCKER_REGISTRY_PASSWORD: Password for the Docker registry (when not specified, does not release to DockerHub)GITHUB_OAUTH_TOKEN: GitHub personal access token for deploying binaries to the release pageGITHUB_REPOSITORY_URL: Clone URL of the GitHub repository (when not specified, does not release to GitHub)GITHUB_SSH_DEPLOY_KEY: Base64 encoded private key that matches a public key listed in your Deploy Keys for the project. Run make ssh.keys to generate this.Y
暂无开放 Issues,或尚未同步最近议题。