Description
Implements native code formatting functionality similar to gofmt/gofumpt as a built-in feature.
Commands
Basic Format Command
tlin fmt [flags] [path...]
Formats the code in the specified paths. If no path is specified, it reads from stdin.
Flags
General Options
-l, --list
- List files that would be reformatted
- Does not actually format the files
-w, --write
- Write formatted content to source files
- Without this flag, prints to stdout
-d, --diff
- Display diffs of formatting changes
-s, --simplify
- Simplify code where possible (like gofumpt)
Style Options
--indent-style=<tab|space>
- Indentation style (default: tab)
--indent-width=<n>
- Number of spaces per indentation level when using spaces (default: 4)
--line-length=<n>
- Maximum line length (default: 100)
--no-rewrite-imports
- Disable import block rewriting/reordering
Examples
# Format a single file
tlin fmt file.gno
# Format and overwrite multiple files
tlin fmt -w file1.gno file2.gno
# Format all Go files in current directory and subdirectories
tlin fmt -w .
# Show formatting changes without applying them
tlin fmt -d file.gno
# List files that need formatting
tlin fmt -l .
# Format using spaces instead of tabs
tlin fmt --indent-style=space file.gno
# Format with simplified code style
tlin fmt -s file.gno
Behavior
Code Simplification (-s flag)
Integrate with auto fixer
When the -s flag is used, the formatter will apply additional simplifications similar to gofumpt:
-
Standardize empty lines
- Single empty line between functions
- No empty lines at start/end of block
- Group related blocks with empty lines
-
Import blocks
-
Code patterns
- Remove redundant type declarations
- Simplify redundant boolean expressions
- Use short variable declarations where possible
Exit Codes
- 0: Success (no formatting changes needed or changes applied successfully)
- 1: Syntax errors in input
- 2: Usage error (invalid flags, etc.)
Configuration
The formatter can be configured through .tlin.yaml configuration file:
formatter:
indent-style: tab
indent-width: 4
line-length: 100
simplify: false
rewrite-imports: true
Command line flags take precedence over configuration file settings.
Description
Implements native code formatting functionality similar to
gofmt/gofumptas a built-in feature.Commands
Basic Format Command
Formats the code in the specified paths. If no path is specified, it reads from stdin.
Flags
General Options
-l, --list-w, --write-d, --diff-s, --simplifyStyle Options
--indent-style=<tab|space>--indent-width=<n>--line-length=<n>--no-rewrite-importsExamples
Behavior
Code Simplification (-s flag)
When the
-sflag is used, the formatter will apply additional simplifications similar to gofumpt:Standardize empty lines
Import blocks
Code patterns
Exit Codes
Configuration
The formatter can be configured through
.tlin.yamlconfiguration file:Command line flags take precedence over configuration file settings.