gofmt -d

1 개요[ | ]

gofmt -d
  • gofmt에 맞출 경우, 변경되는 내용(diff) 조회
gofmt -d go파일.go
# 또는
gofmt -d 디렉토리

2 파일 1개 지정[ | ]

# cat main.go
package main
import "fmt"
func main() {
        fmt.Println("hello world")
}
# gofmt -d main.go
diff main.go.orig main.go
--- main.go.orig
+++ main.go
@@ -1,5 +1,7 @@
 package main
+
 import "fmt"
+
 func main() {
        fmt.Println("hello world")
 }

3 디렉토리 지정[ | ]

# gofmt -d .
diff main.go.orig main.go
--- main.go.orig
+++ main.go
@@ -1,5 +1,7 @@
 package main
+
 import "fmt"
+
 func main() {
        fmt.Println("hello world")
 }
diff temp/greet.go.orig temp/greet.go
--- temp/greet.go.orig
+++ temp/greet.go
@@ -1,5 +1,7 @@
 package temp
+
 import "fmt"
+
 func greet() {
        fmt.Println("hello world")
 }

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}