golines is a code formatter that can detect and shorten line sof code for readability. By default, it wraps code that exceed 100 characters.
Example:
package main
import "fmt"
func main() {
// Long function call
fmt.Println("This is a really really really long string that golines should wrap automatically when formatting")
// Long struct literal
person := Person{FirstName: "Jonathan", LastName: "Smithsonian", Address: "1234 Extremely Long Street Name That Will Wrap", Age: 42, Occupation: "Software Engineer with a very long title"}
fmt.Println(person)
}
type Person struct {
FirstName string
LastName string
Address string
Age int
Occupation string
}
Run golines . and it will output the following. Notice the lines that were wrapped.
package main
import "fmt"
func main() {
// Long function call
fmt.Println(
"This is a really really really long string that golines should wrap automatically when formatting",
)
// Long struct literal
person := Person{
FirstName: "Jonathan",
LastName: "Smithsonian",
Address: "1234 Extremely Long Street Name That Will Wrap",
Age: 42,
Occupation: "Software Engineer with a very long title",
}
fmt.Println(person)
}
type Person struct {
FirstName string
LastName string
Address string
Age int
Occupation string
}