gosrt

command module
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 13 Imported by: 0

README ¶

gosrt

gosrt sorts top-level symbols in Go code.

âš  gosrt is still in early development. It might work, it might destroy your code! Only use it on code under version control.

The order is the same as that of godoc, i.e:

  1. Package declarations, imports, ‘loose’ comments
  2. Constants
  3. Variables
  4. Functions (except constructors), alphabetically
  5. Types:
    1. Type declaration
    2. Constructors, alphabetically
    3. Methods, alphabetically

💾 Installation

go install gitlab.com/biffen/gosrt@latest

⌨ Usage

See usage.txt.

Example

package example

func Zebra() { /* … */ }

func NewOcelot() (*Ocelot, error) { /* … */ }

type Ocelot struct { /* … */ }

func (o *Ocelot) Close() error { /* … */ }

var (
    global = 42
)

func Albatross() { /* … */ }

func (o *Ocelot) String() string { /* … */ }
gosrt -w example.go
package example

var (
    global = 42
)

func Albatross() { /* … */ }

func Zebra() { /* … */ }

type Ocelot struct { /* … */ }

func NewOcelot() (*Ocelot, error) { /* … */ }

func (o *Ocelot) Close() error { /* … */ }

func (o *Ocelot) String() string { /* … */ }

🪲 Bugs

If you find a bug don’t be surprised. But please report it at https://gitlab.com/biffen/gosrt/issues.

License

gosrt is licensed under the MIT license.

Documentation ¶

Overview ¶

Package gosrt sorts top-level symbols in Go code.

For usage documentation see <https://gitlab.com/biffen/gosrt> or `godoc -h`.

Package main is the code that runs the gosrt utility.

Directories ¶

Path Synopsis
Package internal contains the internals of gosrt.
Package internal contains the internals of gosrt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL