An open API service indexing awesome lists of open source software.

https://github.com/switchupcb/xstruct

xstruct extracts any package's structs, functions, or global variables to a single file.
https://github.com/switchupcb/xstruct

code-generation code-generator extract generator go golang

Last synced: about 1 year ago
JSON representation

xstruct extracts any package's structs, functions, or global variables to a single file.

Awesome Lists containing this project

README

          

# Extract a package's structs, functions, or global variables.

[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4.svg?style=for-the-badge&logo=appveyor&logo=appveyor)](https://pkg.go.dev/github.com/switchupcb/xstruct)
[![License](https://img.shields.io/github/license/switchupcb/xstruct.svg?style=for-the-badge)](https://github.com/switchupcb/xstruct/blob/main/LICENSE)

Use `xstruct` to stop wasting time refactoring and debugging projects.

## What is xstruct?

`xstruct` helps you extract any package's structs, functions, or global variables to a single file.

## Table of Contents

| Topic |
| :------------------------------------------------------ |
| [Using `xstruct`](#how-do-you-use-xstruct) |
| [Usecases](#when-do-you-use-xstruct) |
| [License](#what-is-the-license) |
| [License Exception](#what-can-you-do-with-this-license) |

## How do you use xstruct?

Install the command line tool: `xstruct`.

```
go install github.com/switchupcb/xstruct@latest
```

Run the executable with the following flags.

```bash
xstruct -d relative/path/to/dir
```

| Flag | Description | Usage |
| :--- | :-------------------------------------- | :--------------------------------------------------- |
| `-d` | Directory to extract. | `-d relative/path/to/dir` (`/...` for nested search) |
| `-p` | Set the output file's package. | `-p xstruct` (`xstruct` by default) |
| `-g` | Extract global variables and constants. | `-g` |
| `-f` | Extract function declarations. | `-f` |
| `-s` | Sort the extracted objects. | `-s` |
| `>` | Pipe standard output to a file. | `> file.go` |

_Note: Using `-g` and `-f` extracts additional declarations **in addition** to structs._

## When do you use xstruct?

You can use `xstruct` to stop wasting time refactoring and debugging projects.

**Here is Open Source Software using `xstruct`.**

| Software | Description | `xstruct` Use |
| :--------------------------------------------- | :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------- |
| [`disgo`](https://github.com/switchupcb/disgo) | API Wrapper (SDK Client) | Disgo uses `xstruct` to combine a Go type library into a single file, which code is generated from. |
| [`dbgo`](https://github.com/switchupcb/dbgo) | Database Consumer Package Generator | `dbgo` uses `xstruct` to combine generated database models into a single file, which can be used with an interpreter. |

## What is the license?

`xstruct` uses an [AGPLv3 License](https://www.gnu.org/licenses/agpl-3.0.en.html).

## What can you do with this license?

**Code generated by `xstruct` can be used without restriction (including proprietary and commercial usage) since generated code is not considered a derivative work.** However, modifications to the `xstruct` Software Source Code or implementing `xstruct` in a larger work programmatically requires you to adhere to the AGPLv3 License.

_Read the [GPL FAQ](https://www.gnu.org/licenses/gpl-faq.html) for more information._

## What is a license exception?

A license exception lets you modify and use `xstruct` programmatically without restriction.

You can receive a license exception for `xstruct` by contacting SwitchUpCB using the [`xstruct` License Exception Inquiry Form](https://switchupcb.com/xstruct-license-exception/).