package main
import "fmt"
func plus(a int, b int) int {
return a + b
}
}
func plusPlus(a, b, c int) int {
return a + b + c
}
func main() {
res := plus(1, 2)
fmt.Println("1+2 =", res)
res = plusPlus(1, 2, 3)
fmt.Println("1+2+3 =", res)
}
This is my Go Source code. gofmt -e my_file.go
is working But I am not able to write the errors to a text file.
gofmt
will output the errors to the standard error. You can simply redirect the standard error stream of gofmt
to a file on unix systems like this:
gofmt -e my_file.go 2>a.txt
Checking it:
more a.txt
Output:
my_file.go:8:1: expected declaration, found '}'