导出的const应该有一个注释

时间:2016-06-17 18:06:28

标签: go

我正试图从这样的方式导出常量:

package log

const (
    FATAL = iota // fatal errors
    ERROR = iota // errors might happend
    DEBUG = iota // debug mode
) // const for logging levels

但是我得到了golint错误:

exported const FATAL should have comment  (or a comment on this block) or be unexported (golint)

这是正确的,我在获取log.FATAL等访问权限时遇到错误。

2 个答案:

答案 0 :(得分:11)

文档的评论总是紧接在他们记录的内容之前。

$gpx = simplexml_load_file($folder.$file);
$trasa ="'LINESTRING(";
foreach ($gpx->trk->trkseg->trkpt as $trkpt) {
    $lat = (string) $trkpt['lat'];
    $lon = (string) $trkpt['lon'];
    $trasa .= $lon;
    $trasa .=" ";
    $trasa .= $lat;
    $trasa .=",";
}
$trasa =rtrim($trasa,",");
$trasa .=")',0";
unset($gpx);
$ins = @mysql_query("INSERT INTO punktytras(nick,punkty) VALUES('$nick', LineFromText($trasa))");

答案 1 :(得分:9)

您还可以为一组常量提供注释:

// Comment
const (
    FATAL = iota
    ERROR
    DEBUG
)