
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
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.
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 |
API Wrapper (SDK Client) |
Disgo uses xstruct to combine a Go type library into a single file, which code is generated from. |
What is the license?
xstruct
uses an AGPLv3 License.
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 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.