> For the complete documentation index, see [llms.txt](https://rodneycheung.gitbook.io/handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rodneycheung.gitbook.io/handbook/3.-yu-yan-pian/golang/dai-ma-gui-fan/avoid_naked_params.md).

# 避免参数语义不明确

函数调用中的`意义不明确的参数`可能会损害可读性。当参数名称的含义不明显时，请为参数添加`C-style`的注释 (`/* ... */`)。

以`func printInfo(name string, isLocal, done bool)`为例：

```go
// bad usage
printInfo("foo", true, true)

// good usage
printInfo("foo", true /* isLocal */, true /* done */)
```

对于上面的示例代码，还有一种更好的处理方式是将上面的 `bool` 类型换成自定义类型。将来，该参数可以支持不仅仅局限于两个状态（true/false）。

```go
type Region int

const (
  UnknownRegion Region = iota + 1
  Local
)

type Status int

const (
  StatusReady = iota + 1
  StatusDone
  // Maybe we will have a StatusInProgress in the future.
)

func printInfo(name string, region Region, status Status)
```
