gojen

command module
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

gojen

Release Upload Binary Go Report Card codecov

Define your go project's configuration using a json config. This config can be used to generate a new go project for you, and can also create configs for different tools.

This project also helps you maintain your code after the scaffolding process, simply run gojen to vendor deps, tidy them, fmt your code, golangci-lint run, go test and go build your code.

$ gojen
ℹ  | Setup | running go mod vendor
ℹ  | Setup | running go mod tidy
ℹ  | Setup | running go fmt
ℹ  | Lint | running go linter
✅  | Lint | go linter passed
ℹ  | Test | running go test
✅  | Test | go test passed
ℹ  | Build | running go build
✅  | Build | go build passed

Features

Release workflow

Github actions workflow that simply runs the golangci-lint action, followed by gojen to vendor/tidy/fmt/test/build our code, a release job that creates a github release, and finally another workflow that uploads our built binary to the release we just created.

Is triggered on a push to the defaultReleaseBranch inside gojen.json.

Build workflow

Github workflow that runs the golangci-lint action, followed by gojen. Is triggered on pull request creation.

License

"Apache-2.0"
"Artistic-2.0"
"GPL-3.0-WITH-GCC-exception-3.1"
"LGPL-2.1-or-later"
"MIT-0"
"MPL-2.0"
"PHP-3.01"
"Unlicense"
"ZPL-2.1"
"Artistic-1.0"
"GPL-2.0-or-later"
"GPL-3.0-or-later"
"LGPL-3.0-or-later"
"MIT"
"OFL-1.1"
"Ruby"
"WTFPL"

Gitignore

Define all your gitignore entries inside gojen.json

Codeowners

Define all your codeowners inside gojen.json

Golangci-lint

Lint your code using golangci-lint

go test

Test your code using go test. You can also append test arguments to go test by adding your arguments to the goTestArgs slice inside gojen.json

go build

Build your binary using the go build command. You can also append build arguments to go build by adding your arguments to the goBuildArgs slice inside gojen.json

Getting started

Install binary

go install github.com/hunter-thompson/gojen

Create a config for your project

printf "{
  "name": "gojen",
  "description": "Go project generator",
  "repository": "github.com/Hunter-Thompson/gojen",
  "goVersion": "1.17",
  "authorName": "Hunter Thompson",
  "authorEmail": "hunter@example.com",
  "authorOrganization": "Hunter-Thompson",
  "license": "Apache-2.0",
  "readme": true,
  "release": true,
  "buildWorkflow": true,
  "githubToken": "GIT_TOKEN",
  "defaultReleaseBranch": "master",
  "isGojen": false,
  "gitignore": [
	  ".vscode",
	  ".idea",
  ],
  "codeOwners": [
	  "* Hunter-Thompson",
  ],
  "goLinter": true,
  "goTest": true,
  "codeCov": true,
  "goTestArgs": [
	  "-v",
	  "-cover",
	  "./..."
  ],
  "goBuildArgs: ["arg1"],
}" > gojen.json

Generate project

gojen new

Runing gojen after the project has been created does the following things:

  • go mod vendor
  • go mod tidy
  • go fmt
  • golangci-lint
  • go test
  • go build

Known issues

  1. The default GITHUB_TOKEN cannot be used for the release workflow since if the release is created by the github bot, the upload binary workflow will not run.

So please upload a GITHUB token inside the repo secrets, and add the key to the secret inside gojen.json

Example project

https://github.com/Hunter-Thompson/test-gojen https://github.com/Hunter-Thompson/gojen - yes gojen uses gojen : )

Notes

This project was inspired by #projen/projen.

Documentation

Overview

Copyright © 2021 Aatman <aatman@auroville.org.in>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis
pkg
license
sources: license-text/Apache-2.0.txt license-text/Artistic-1.0.txt license-text/Artistic-2.0.txt license-text/GPL-2.0-or-later.txt license-text/GPL-3.0-WITH-GCC-exception-3.1.txt license-text/GPL-3.0-or-later.txt license-text/LGPL-2.1-or-later.txt license-text/LGPL-3.0-or-later.txt license-text/MIT-0.txt license-text/MIT.txt license-text/MPL-2.0.txt license-text/OFL-1.1.txt license-text/PHP-3.01.txt license-text/Ruby.txt license-text/Unlicense.txt license-text/WTFPL.txt license-text/ZPL-2.1.txt
sources: license-text/Apache-2.0.txt license-text/Artistic-1.0.txt license-text/Artistic-2.0.txt license-text/GPL-2.0-or-later.txt license-text/GPL-3.0-WITH-GCC-exception-3.1.txt license-text/GPL-3.0-or-later.txt license-text/LGPL-2.1-or-later.txt license-text/LGPL-3.0-or-later.txt license-text/MIT-0.txt license-text/MIT.txt license-text/MPL-2.0.txt license-text/OFL-1.1.txt license-text/PHP-3.01.txt license-text/Ruby.txt license-text/Unlicense.txt license-text/WTFPL.txt license-text/ZPL-2.1.txt

Jump to

Keyboard shortcuts

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