Use xstruct to stop wasting time refactoring and debugging projects.
xstruct helps you extract any package's structs, functions, or global variables to a single file.
| Topic |
|---|
Using xstruct |
| Usecases |
| License |
| License Exception |
Install the command line tool: xstruct.
go install github.com/switchupcb/xstruct@latest
Run the executable with the following flags.
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.
You can use xstruct to stop wasting time refactoring and debugging projects.
Here is Open Source Software using xstruct.
| Software | Description | xstruct Use |
|---|---|---|
disgo |
API Wrapper (SDK Client) | Disgo uses xstruct to combine a Go type library into a single file, which code is generated from. |
dbgo |
Database Consumer Package Generator | dbgo uses xstruct to combine generated database models into a single file, which can be used with an interpreter. |
xstruct uses an AGPLv3 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 for more information.
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.