Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 检查数组[键]是否已设置?抛出:索引超出范围_Go - Fatal编程技术网

Go 检查数组[键]是否已设置?抛出:索引超出范围

Go 检查数组[键]是否已设置?抛出:索引超出范围,go,Go,若我试图访问数组中不存在的密钥,我会得到 抛出:索引超出stacktrace的范围 如何检查tmp[键]“是否已设置” 这一准确操作: if len(url) > 1 { tmp := strings.Split(url[1],"=",0); if len(tmp) >1{ sess = tmp[1]; } } 你能发布你的代码吗?我没有得到同样的厄洛斯。我认为这是唯一有效的方法。我不认为有任何方法可以从Go中获得某种“超出范围”的异常。

若我试图访问数组中不存在的密钥,我会得到 抛出:索引超出stacktrace的范围

如何检查tmp[键]“是否已设置”

这一准确操作:

if len(url) > 1 {
    tmp := strings.Split(url[1],"=",0);
    if len(tmp) >1{
        sess = tmp[1];
    }
}

你能发布你的代码吗?我没有得到同样的厄洛斯。我认为这是唯一有效的方法。我不认为有任何方法可以从Go中获得某种“超出范围”的异常。