format

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

Go+ Code Style

TODO

Specification

No package main
package main

func f() {
}

will be converted into:

func f() {
}
No func main
package main

func main() {
    a := 0
}

will be converted into:

a := 0
Replace fmt.Print to builtin
import "fmt"

n, err := fmt.Println("Hello world")

will be converted into:

n, err := echo("Hello world")

Note:

  • Convert fmt.Errorf => errorf
  • Convert fmt.Fprint => fprint
  • Convert fmt.Fprintf => fprintf
  • Convert fmt.Fprintln => fprintln
  • Convert fmt.Print => print
  • Convert fmt.Printf => printf
  • Convert fmt.Println => echo
  • Convert fmt.Sprint => sprint
  • Convert fmt.Sprintf => sprintf
  • Convert fmt.Sprintln => sprintln
Command style first
import "fmt"

fmt.Println()
fmt.Println(fmt.Println("Hello world"))

will be converted into:

echo
echo echo("Hello world")

Note:

  • Only the outermost function call statement is converted into command style. So fmt.Println(fmt.Println("Hello world")) is converted into echo echo("Hello world"), not echo echo "Hello world".
pkg.Fncall starting with lowercase
import "math"

echo math.Sin(math.Pi/3)

will be converted into:

echo math.sin(math.Pi/3)
Funclit of params convert to lambda in fncall (skip named results)
echo(demo(func(n int) int {
	return n+100
}))

echo(demo(func(n int) (v int) {
	return n+100
}))

onStart(func() {
	echo("start")
})

will be converted into:

echo demo(n => n + 100)

echo demo(func(n int) (v int) {
	return n + 100
})

onStart => {
	echo "start"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gopstyle

func Gopstyle(file *ast.File)

func GopstyleSource

func GopstyleSource(src []byte, filename ...string) (ret []byte, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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