From 21fffc446b4f45e87c724e63afa0f05a36ff87cf Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 8 Sep 2015 21:45:45 +0800 Subject: [PATCH] make golint happy parser.go --- parser.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/parser.go b/parser.go index cf8dee22..dd468c1c 100644 --- a/parser.go +++ b/parser.go @@ -42,13 +42,13 @@ func init() { ` var ( - lastupdateFilename string = "lastupdate.tmp" + lastupdateFilename = "lastupdate.tmp" commentFilename string pkgLastupdate map[string]int64 genInfoList map[string][]ControllerComments ) -const COMMENTFL = "commentsRouter_" +const coomentPrefix = "commentsRouter_" func init() { pkgLastupdate = make(map[string]int64) @@ -56,7 +56,7 @@ func init() { func parserPkg(pkgRealpath, pkgpath string) error { rep := strings.NewReplacer("/", "_", ".", "_") - commentFilename = COMMENTFL + rep.Replace(pkgpath) + ".go" + commentFilename = coomentPrefix + rep.Replace(pkgpath) + ".go" if !compareFile(pkgRealpath) { Info(pkgRealpath + " has not changed, not reloading") return nil @@ -129,9 +129,11 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat func genRouterCode() { os.Mkdir(path.Join(workPath, "routers"), 0755) Info("generate router from comments") - var globalinfo string - sortKey := make([]string, 0) - for k, _ := range genInfoList { + var ( + globalinfo string + sortKey []string + ) + for k := range genInfoList { sortKey = append(sortKey, k) } sort.Strings(sortKey)