zipline

module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT

README

zipline

Go Report Card MIT License release pkg.go.dev

Zipline is a tool to help build RESTful APIs in Go. The intent is to enable separation of HTTP/S request/response marshaling and un-marshaling from request/response processing, apply consistent request/response handling, and generate API documentation, without requiring a runtime dependency on any additional packages. It can be used with any of the popular routing packages. The examples in this repo use chi.

It's a template driven code generation tool. An example of a template is here, without it the tool doesn't do anything. Once a similar template has been created, simply run zipline ./... from the Go project root.

It will generate the following files:

Check here for examples.

Ensure GO environment is setup properly using GOPATH if GO111MODULE=off

zipline will attempt to detect package with bindings.go file and generate the bindings_gen.go file in the same location.

You can read more about the differences and implications here: https://insujang.github.io/2020-04-04/go-modules/

  • export GOPATH=<go directory>
  • export GOBIN=GOPATH/bin
  • export PATH=$GOBIN:$PATH

Installation

  • Brew tap
    • brew tap bilal-bhatti/homebrew-taps
    • brew install zipline

OR install from source

  • Get and install
    • go install github.com/bilal-bhatti/zipline/cmd/zipline@latest

Usage

To explore the examples included in this repo navigate to cd <path to project>/zipline and run zipline ./... from your project root. Use zipline --debug ./... to enable trace logging to help troubleshoot problems.

Troubleshooting

VS Code uses gopls as the language server and can run into trouble parsing the bidnings.go file because of the ziplinegen build tag. To fix this, gopls needs to be made aware of the build tag, so it can analyze the code properly. Add the following setting to VS Code.

“gopls”: {
    “buildFlags”: [“-tags=ziplinegen”],
}

Directories

Path Synopsis
cmd
example
web

Jump to

Keyboard shortcuts

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