Indentation in Go: tabs or spaces?

前端 未结 2 1925
甜味超标
甜味超标 2021-01-30 19:17

Is there a standard Google Go coding conventions document somewhere that sets whether tabs or spaces are preferred for indentation in Go source code?

What is the official

2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 19:42

    The official recommendation is formatting your code with

    go fmt
    

    or using the gofmt command directly

    gofmt -w .
    

    You can read more about it here on the golang.org blog, or from the Effective go document:

    Indentation
    We use tabs for indentation and gofmt emits them by default. Use spaces only if you must.

提交回复
热议问题