From d54f43b3d18745576f51e49e2a581f4a80431e8b Mon Sep 17 00:00:00 2001 From: Ruan Bekker Date: Tue, 16 Jun 2020 02:04:14 +0200 Subject: [PATCH] day 1 - add go fmt example --- go-detailed-log/day-01/04-go-fmt-package.md | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 go-detailed-log/day-01/04-go-fmt-package.md diff --git a/go-detailed-log/day-01/04-go-fmt-package.md b/go-detailed-log/day-01/04-go-fmt-package.md new file mode 100644 index 00000000000..8677bf73766 --- /dev/null +++ b/go-detailed-log/day-01/04-go-fmt-package.md @@ -0,0 +1,50 @@ +# go fmt command + +The go fmt command formats your code, which allows a consistent standard of formatting + +The go fmt command and fmt package are two different things + +## Pronounciation + +go fmt is pronounced as "go fumt" + +## Example formatting + +Create a file with strange formatted style: + +``` +$ cat app.go +package main + +import "fmt" + +func main(){ + fmt.Println("hello") + } +``` + +After we run `go fmt` on our code, we will notice its formatted: + +``` +$ go fmt app.go +app.go +``` + +Verify that the code was formatted: + +``` +$ cat app.go +package main + +import "fmt" + +func main() { + fmt.Println("hello") +} +``` + +To run this with a bunch of files, in the current working directory: + +``` +$ go fmt ./.. +```