Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exported const should have a comment

Tags:

go

I'm trying to export a constant from a go like this:

package log

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

But I'm getting golint error :

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

And it's right I'm getting later error in getting access to log.FATAL etc.

like image 759
Luman75 Avatar asked Jun 17 '16 18:06

Luman75


1 Answers

Also you can provide a comment for a set of constants:

// Log level
const (
    Debug = iota
    Trace
    Info
    Warn
    Error
    Panic
    Fatal
)
like image 77
Kaveh Shahbazian Avatar answered Oct 06 '22 09:10

Kaveh Shahbazian