在代码中,我尝试做一些操作
is_html := false;
// Check, if HTMl is exist
for i := 0; i < len(modules_arr); i++ {
if modules_arr[i] == "html" { is_html := true }
}
if is_html ==true
{
fmt.Printf("%v", "asdasd")
}
Run Code Online (Sandbox Code Playgroud)
但是我收到一个错误:
./api.go:26: missing condition in if statement
./api.go:26: is_html == true evaluated but not used
Error: process exited with code 2.
Run Code Online (Sandbox Code Playgroud)
if语句需要{在同一行
这意味着你做不到
if is_html ==true
{
fmt.Printf("%v", "asdasd")
}
Run Code Online (Sandbox Code Playgroud)
正确的代码是
if is_html ==true {
fmt.Printf("%v", "asdasd")
}
Run Code Online (Sandbox Code Playgroud)
请阅读http://golang.org/doc/effective_go.html#semicolons以获得更好的理解
| 归档时间: |
|
| 查看次数: |
23719 次 |
| 最近记录: |