根据作者的说法:

Golint is a linter for Go source code.
Golint differs from gofmt. Gofmt reformats Go source code, whereas
golint prints out style mistakes. Golint differs from govet. Govet is concerned with correctness, whereas
golint is concerned with coding style. Golint is in use at Google, and it
seeks to match the accepted style of the open source Go project.

一句话就是Golint用于检查go代码中不够规范的地方。

一、编译及生成可执行程序

1、下载golang 的 lint,下载地址:https://github.com/golang/lint

2、解压文件到$GOPATH/src/github.com/golang/lint

3、到目录$GOPATH/src/github.com/golang/lint/golint中运行go build ./

4、在当前目录有golint的可执行程序

当然,最简单的方式是:

go get github.com/golang/lint
go install github.com/golang/lint

二、执行方式:

golint 文件名或者目录

检查结果如下:

import-dot.go:6:8: should not use dot imports
else.go:11:9: if block ends with a return statement, so drop this else and outdent its block
sort.go:11:1: exported method T.Len should have comment or be unexported
sort.go:20:1: exported method U.Other should have comment or be unexported

从上面输出可以看到,golint对go代码给出的建议。

golint 会检查的内容:

变量名规范
变量的声明,像var str string = "test",会有警告,应该var str = "test"
大小写问题,大写导出包的要有注释
x += 1 应该 x++
等等……

使用注意事项

如果使用命令下载安装不通的情况下,建议使用第一种方法

在使用golint命令检查时,需要把golint.exe文件放在你要检查的名录下,这样在使用命令时才能找到该执行程序。

Golint的简易使用方法的更多相关文章

  1. ORACLE PL/SQL 中序列(sequence)的简易使用方法介绍

    如果我是C罗 原文 ORACLE PL/SQL 中序列(sequence)的简易使用方法介绍 sequence在ORACLE中应用十分广泛,就是序列号的意思,会自动增加指定变数,如逐次增加1或者2或者 ...

  2. IOS中集合视图UICollectionView中DecorationView的简易使用方法

    转载自:   http://www.it165.net/pro/html/201312/8575.html Decoration View是UICollectionView的装饰视图.苹果官方给的案例 ...

  3. .Net 下采用GET/POST/SOAP方式动态调用WebService的简易灵活方法(C#) [轉]Redfox

    一直以来,我都为动态调用WebService方法而烦恼.在.Net环境下,最常用的方法就是采用代理类来调用WebService,可以通过改变代理类的Url属性来实现动态调用,但当xmlns改变时就会出 ...

  4. TuSDK 简易使用方法 持有图片对象方式

    TuSDK 为涂图照相应用的SDK,打包后文件大小约为5M,缺点为包比较大,且图片清晰度较差一些,优点为直接可以引用滤镜贴纸,方便易用.   使用方法如下:    1.AppDelegate.m 中加 ...

  5. jquery tips简易使用方法 新手必看

    使用jquery1.12.4以上版本 使用jquery插件 tips .beg-pull-right 点击时的选择器 在这里写的是一个类选择器   记得引入jquery $(".beg-pu ...

  6. tar 命令 简易使用方法

    创建压缩文件方法 tar zcf 压缩包存放位置 压缩那个目录/内容 (压缩) 例:在/data目录下压缩/etc/目录,并创建名称为etc.tar.gz [root@web01 /]# tar zc ...

  7. 三种初步简易的方法求解数值问题 of C++

    1. “二分法解方程” 在二分法中,从区间[a,b]开始,用函数值f(a)与f(b)拥有相反的符号.如果f在这个区间连续,则f的图像至少在x=a,x=b之间穿越x轴一次,因此方程f(x)=0在[a,b ...

  8. ADB简易安装方法

    ADB安装方法: 1. 下载ADB程序 下载地址: 链接:https://pan.baidu.com/s/1CfQL51pBz-2Wk_cYfJYXUw  提取码:bjp8 2. 配置环境变量 pat ...

  9. Windows下.svn文件夹的最简易删除方法(附linux)

    如果想删除Windows下的.svn文件夹,通过手动删除的渠道是最麻烦的,因为每个文件夹下面都存在这样的文件.下面是一个好办法:建立一个文本文件,取名为kill-svn-folders.reg(扩展名 ...

随机推荐

  1. 深入理解net core中的依赖注入、Singleton、Scoped、Transient(三)

    相关文章: 深入理解net core中的依赖注入.Singleton.Scoped.Transient(一) 深入理解net core中的依赖注入.Singleton.Scoped.Transient ...

  2. 【Java】读写文本文件

    package rw; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutput ...

  3. clean-css

    What is clean-css? Clean-css is a fast and efficient Node.js library for minifying CSS files. Accord ...

  4. python及pandas,numpy等知识点技巧点学习笔记

    python和java,.net,php web平台交互最好使用web通信方式,不要使用Jypython,IronPython,这样的好处是能够保持程序模块化,解耦性好 python允许使用'''.. ...

  5. SVN合并时报错:Merge tracking not allowed with missing subtrees; try restoring these items

    使用的是TortoiseSVN; Merge tracking not allowed with missing subtrees; try restoring these items 下面会有跟着几 ...

  6. C# 数据上传(自用笔记)

    #region 数据上传 [HttpPost] public ActionResult UploadFile() { HttpFileCollectionBase files = Request.Fi ...

  7. 阿里云ECS服务器环境搭建 ubuntu 16.04 图形界面的安装

    https://blog.csdn.net/zwq912318834/article/details/80528374

  8. [翻译] AnchoredFloatView

    AnchoredFloatView Float View over TableView to indicate selected row direction Float View 可以用来指示 Tab ...

  9. MySQL 索引的介绍与应用

    Mysql索引 一. mysql 索引 索引是对数据库表中一列或多列的值进行排序的一种结构,使用索引可快速访问数据库表中的特定信息. 二:MySQL索引类型 按存储结构区分:聚集索引(又称聚类索引,簇 ...

  10. MVC5开发环境的配置

    如果你打算在VS2012上开发MVC5,请通过WPI来安装此组件:ASP.NET and Web Tools 2013.1 version