项目作者: strackovski

项目描述 :
Generate structs from JSON definitions
高级语言: Go
项目地址: git://github.com/strackovski/structer.git
创建时间: 2019-04-07T14:05:54Z
项目社区:https://github.com/strackovski/structer

开源协议:Apache License 2.0

下载



NV3


GO STRUCTER

Generate structs from JSON definitions



Issues

Wiki

Examples



Overview

Build
Coverage
License
Water

A JSON-to-struct generator for Go

Because sometimes you just have to generate a struct from json.

Installation

Requirements

  • Go 1.11

Quick Start

Install structer using the installation script by executing the following command (execute in directory with write permissions):

  1. curl https://s3.eu-central-1.amazonaws.com/structer/dist/structer_installer.sh | bash

The installer script is available for download here.

When installed, run the structer command from terminal:

  1. structer

You should see the following output:

  1. Structer is a tool for creating struct types from definitions stored as JSON.
  2. Usage:
  3. structer [command]
  4. Available Commands:
  5. help Help about any command
  6. make Makes a struct from JSON data.
  7. Flags:
  8. --config string config file (default is $HOME/.structer.yaml)
  9. -h, --help help for structer
  10. -t, --toggle Help message for toggle
  11. Use "structer [command] --help" for more information about a command.

To get familiar with the main command, make, use the help option

  1. structer help make
  1. Makes a struct from JSON data.
  2. Usage:
  3. structer make [flags]
  4. Flags:
  5. --format string the format of the input (default "json")
  6. -h, --help help for make
  7. --in string path to input file or directory
  8. --out string path to output directory (default "generated")
  9. Global Flags:
  10. --config string config file (default is $HOME/.structer.yaml)

Use structer make providing the path to json file in the --in parameter:

  1. structer make --in <PATH_TO_JSON_FILE>

:bulb: TIP

For more examples visit the Examples directory.

Download Binaries

:bulb: TIP

Download the latest release of structer for your platform.

  • The fastest way to install is by downloading and running the installer script as shown in Quick Start
  • You can download the src archive if you’d like to build this tool form source. See [Building From Source]
    (#building-from-source) for details.
File name Kind OS Arch Size Checksum
structer-installer.sh Installer - - 3.4KB View
structer_0.1.0_darwin_386 Archive OSX x86 10.9MB View
structer_0.1.0_darwin_amd64 Archive OSX x86-64 12.3MB View
structer_0.1.0_linux_386 Archive Linux x86 10.9MB View
structer_0.1.0_linux_amd64 Archive Linux x86-64 12.9MB View
structer_0.1.0_freebsd_386 Archive freebsd x86 10.9MB View
structer_0.1.0_freebsd_amd64 Archive freebsd x86-64 12.3MB View
structer_0.1.0_windows_386 Archive Windows x86 10.9MB View
structer_0.1.0_windows_amd64 Archive Windows x86-64 12.4MB View

Builds for other platforms available here.

:truck: Release 0.1.0

See release log for more information about the current and previous structer releases.

Building From Source

Either download the source package or clone this repository, cd into the directory where you have the source files, and execute:

  1. make && make install

This will build and install the structer executable to your path.

That’s it. Now you can run:

  1. structer

Makefile offers the following options:

  1. # Start the build process, cross-building all supported platforms:
  2. make
  3. # Start the build process for the current platform:
  4. make current
  5. # Start the build process for a specific platform:
  6. make platform darwin_amd64
  7. # The publish option is reserved for project maintainers.
  8. # It will publish the distributable files to the build server
  9. # after a successful build.
  10. make publish
  11. # Make install assumes there's a build file waiting in the build
  12. # directory, and tries to move it to system path:
  13. make install
  14. # Downloads and installs the prebuilt binary for the current platform:
  15. make web_install

Usage

Make sure you try the Quick Start guide first. See the examples directory for more examples.
Below is a very simple one:

  1. structer
  2. structer help
  3. structer make --in <PATH_TO_JSON_FILE>

Running Tests

:bulb: TIP

TBD

  1. structer test run

Contributing

Contributions are welcome. Check Issues & Roadmap below to see how you can help with priority features, bugs,
tests or
docs.

Contribution guidelines are described in the Contributing document.

Issues and Roadmap

Issue tracker top:

:zap: STR-2 Enable (extendable) multiple input formats

:bulb: STRU-3 TBD

Contact

Feel free to get in touch if you have a question or request in connection to this program or source repository.

Open, public communication is the prefered choice:

Private inquiries over email. Find emails in:

License

Licensed under the Apache License, Version 2.0. See the LICENSE file distributed with this source code for the full text license agreement.


Logo