Repository: qiniu/goc
Pull request #87 (2020-07-31 07:27:13)

Fix golint and ineffassign


Patch:
diff --git a/go.mod b/go.mod
index 1c38ded..91b80f1 100644
--- a/go.mod
+++ b/go.mod
@@ -16,9 +16,9 @@ require (
 	github.com/spf13/pflag v1.0.5
 	github.com/spf13/viper v1.6.2
 	github.com/stretchr/testify v1.5.1
-	golang.org/x/net v0.0.0-20200301022130-244492dfa37a
+	golang.org/x/net v0.0.0-20200625001655-4c5254603344
 	golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
-	golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65
+	golang.org/x/tools v0.0.0-20200730221956-1ac65761fe2c
 	k8s.io/kubernetes v1.13.0
 	k8s.io/test-infra v0.0.0-20200511080351-8ac9dbfab055
 )
diff --git a/go.sum b/go.sum
index 3f22cde..722c912 100644
--- a/go.sum
+++ b/go.sum
@@ -739,6 +739,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
 github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=
 github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs=
 github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA=
 github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg=
@@ -792,6 +793,7 @@ golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPh
 golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
 golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -811,6 +813,7 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl
 golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
 golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
 golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
 golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
@@ -819,6 +822,7 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG
 golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
 golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -850,6 +854,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
 golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -862,6 +868,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
 golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -901,6 +908,8 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
 golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -953,6 +962,8 @@ golang.org/x/tools v0.0.0-20200303214625-2b0b585e22fe h1:Kh3iY7o/2bMfQXZdwLdL9jD
 golang.org/x/tools v0.0.0-20200303214625-2b0b585e22fe/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
 golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65 h1:1KSbntBked74wYsKq0jzXYy7ZwcjAUtrl7EmPE97Iiw=
 golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
+golang.org/x/tools v0.0.0-20200730221956-1ac65761fe2c h1:c5JjBOQWM2pRemVbog00sS+oAdi8tTR+NNRFDwUOrTQ=
+golang.org/x/tools v0.0.0-20200730221956-1ac65761fe2c/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
diff --git a/pkg/build/tmpfolder.go b/pkg/build/tmpfolder.go
index 9a1a08c..f9a027c 100644
--- a/pkg/build/tmpfolder.go
+++ b/pkg/build/tmpfolder.go
@@ -145,7 +145,7 @@ func (b *Build) traversePkgsList() (isMod bool, root string, err error) {
 // and store it in the Build.tmpWorkdingDir
 func (b *Build) getTmpwd() (string, error) {
 	for _, pkg := range b.Pkgs {
-		index := -1
+		var index int
 		var parentPath string
 		if b.IsMod == false {
 			index = strings.Index(b.WorkingDir, pkg.Root)
diff --git a/pkg/cover/delta.go b/pkg/cover/delta.go
index c020583..729f2c5 100644
--- a/pkg/cover/delta.go
+++ b/pkg/cover/delta.go
@@ -18,6 +18,7 @@ package cover
 
 import "sort"
 
+// DeltaCov contains the info of a delta coverage
 type DeltaCov struct {
 	FileName    string
 	BasePer     string
@@ -26,9 +27,10 @@ type DeltaCov struct {
 	LineCovLink string
 }
 
+// DeltaCovList is the list of DeltaCov
 type DeltaCovList []DeltaCov
 
-// get full delta coverage between new and base profile
+// GetFullDeltaCov get full delta coverage between new and base profile
 func GetFullDeltaCov(newList CoverageList, baseList CoverageList) (delta DeltaCovList) {
 	newMap := newList.Map()
 	baseMap := baseList.Map()
@@ -64,7 +66,7 @@ func GetFullDeltaCov(newList CoverageList, baseList CoverageList) (delta DeltaCo
 	return
 }
 
-//get two profile diff cov
+// GetDeltaCov get two profile diff cov
 func GetDeltaCov(newList CoverageList, baseList CoverageList) (delta DeltaCovList) {
 	d := GetFullDeltaCov(newList, baseList)
 	for _, v := range d {
@@ -76,7 +78,7 @@ func GetDeltaCov(newList CoverageList, baseList CoverageList) (delta DeltaCovLis
 	return
 }
 
-//get two profile diff cov of changed files
+// GetChFileDeltaCov get two profile diff cov of changed files
 func GetChFileDeltaCov(newList CoverageList, baseList CoverageList, changedFiles []string) (list DeltaCovList) {
 	d := GetFullDeltaCov(newList, baseList)
 	dMap := d.Map()
@@ -88,14 +90,14 @@ func GetChFileDeltaCov(newList CoverageList, baseList CoverageList, changedFiles
 	return
 }
 
-//calculate two coverage delta
+// Delta calculate two coverage delta
 func Delta(new Coverage, base Coverage) float32 {
 	baseRatio, _ := base.Ratio()
 	newRatio, _ := new.Ratio()
 	return newRatio - baseRatio
 }
 
-//calculate two coverage delta
+// TotalDelta calculate two coverage delta
 func TotalDelta(new CoverageList, base CoverageList) float32 {
 	baseRatio, _ := base.TotalRatio()
 	newRatio, _ := new.TotalRatio()
@@ -111,7 +113,7 @@ func (d DeltaCovList) Map() map[string]DeltaCov {
 	return m
 }
 
-// sort DeltaCovList with filenames
+// Sort sort DeltaCovList with filenames
 func (d DeltaCovList) Sort() {
 	sort.SliceStable(d, func(i, j int) bool {
 		return d[i].Name() < d[j].Name()
@@ -123,10 +125,12 @@ func (c *DeltaCov) Name() string {
 	return c.FileName
 }
 
+// GetLineCovLink get the LineCovLink of the DeltaCov
 func (c *DeltaCov) GetLineCovLink() string {
 	return c.LineCovLink
 }
 
+// SetLineCovLink set LineCovLink of the DeltaCov
 func (c *DeltaCov) SetLineCovLink(link string) {
 	c.LineCovLink = link
 }
diff --git a/pkg/github/github.go b/pkg/github/github.go
index cf965d0..8b9092f 100644
--- a/pkg/github/github.go
+++ b/pkg/github/github.go
@@ -47,8 +47,8 @@ type PrComment interface {
 	GetCommentFlag() string
 }
 
-// GithubPrComment is the entry which is able to comment on Github Pull Requests
-type GithubPrComment struct {
+// GitPrComment is the entry which is able to comment on Github Pull Requests
+type GitPrComment struct {
 	RobotUserName string
 	RepoOwner     string
 	RepoName      string
@@ -60,7 +60,7 @@ type GithubPrComment struct {
 }
 
 // NewPrClient creates an Client which be able to comment on Github Pull Request
-func NewPrClient(githubTokenPath, repoOwner, repoName, prNumStr, botUserName, commentFlag string) *GithubPrComment {
+func NewPrClient(githubTokenPath, repoOwner, repoName, prNumStr, botUserName, commentFlag string) *GitPrComment {
 	var client *github.Client
 
 	// performs automatic retries when connection error occurs or a 500-range response code received (except 501)
@@ -81,7 +81,7 @@ func NewPrClient(githubTokenPath, repoOwner, repoName, prNumStr, botUserName, co
 	tc := oauth2.NewClient(ctx, ts)
 	client = github.NewClient(tc)
 
-	return &GithubPrComment{
+	return &GitPrComment{
 		RobotUserName: botUserName,
 		RepoOwner:     repoOwner,
 		RepoName:      repoName,
@@ -94,7 +94,7 @@ func NewPrClient(githubTokenPath, repoOwner, repoName, prNumStr, botUserName, co
 }
 
 // CreateGithubComment post github comment of diff coverage
-func (c *GithubPrComment) CreateGithubComment(commentPrefix string, diffCovList cover.DeltaCovList) (err error) {
+func (c *GitPrComment) CreateGithubComment(commentPrefix string, diffCovList cover.DeltaCovList) (err error) {
 	if len(diffCovList) == 0 {
 		logrus.Printf("Detect 0 files coverage diff, will not comment to github.")
 		return nil
@@ -110,7 +110,7 @@ func (c *GithubPrComment) CreateGithubComment(commentPrefix string, diffCovList
 }
 
 // PostComment post comment on github. It erased the old one if existed to avoid duplicate
-func (c *GithubPrComment) PostComment(content, commentPrefix string) error {
+func (c *GitPrComment) PostComment(content, commentPrefix string) error {
 	//step1: erase history similar comment to avoid too many comment for same job
 	err := c.EraseHistoryComment(commentPrefix)
 	if err != nil {
@@ -130,7 +130,7 @@ func (c *GithubPrComment) PostComment(content, commentPrefix string) error {
 }
 
 // EraseHistoryComment erase history similar comment before post again
-func (c *GithubPrComment) EraseHistoryComment(commentPrefix string) error {
+func (c *GitPrComment) EraseHistoryComment(commentPrefix string) error {
 	comments, _, err := c.GithubClient.Issues.ListComments(c.Ctx, c.RepoOwner, c.RepoName, c.PrNumber, nil)
 	if err != nil {
 		logrus.Errorf("list PR comments failed.")
@@ -152,7 +152,7 @@ func (c *GithubPrComment) EraseHistoryComment(commentPrefix string) error {
 }
 
 // GetPrChangedFiles get github pull request changes file list
-func (c *GithubPrComment) GetPrChangedFiles() (files []string, err error) {
+func (c *GitPrComment) GetPrChangedFiles() (files []string, err error) {
 	var commitFiles []*github.CommitFile
 	for {
 		f, resp, err := c.GithubClient.PullRequests.ListFiles(c.Ctx, c.RepoOwner, c.RepoName, c.PrNumber, c.opt)
@@ -174,8 +174,8 @@ func (c *GithubPrComment) GetPrChangedFiles() (files []string, err error) {
 	return
 }
 
-// GetCommentFlag get CommentFlag from the GithubPrComment
-func (c *GithubPrComment) GetCommentFlag() string {
+// GetCommentFlag get CommentFlag from the GitPrComment
+func (c *GitPrComment) GetCommentFlag() string {
 	return c.CommentFlag
 }
 
diff --git a/pkg/prow/job.go b/pkg/prow/job.go
index 5d73d53..cebcdad 100644
--- a/pkg/prow/job.go
+++ b/pkg/prow/job.go
@@ -144,7 +144,7 @@ func trimGhFileToProfile(ghFiles []string) (pFiles []string) {
 	return
 }
 
-// filter local profile with changed files and save to j.LocalArtifacts.ChangedProfileName
+// WriteChangedCov filter local profile with changed files and save to j.LocalArtifacts.ChangedProfileName
 func (j *Job) WriteChangedCov(changedFiles []string) error {
 	p, err := ioutil.ReadFile(j.LocalProfilePath)
 	if err != nil {
@@ -175,14 +175,17 @@ func writeLine(file *os.File, content string) {
 	}
 }
 
+// JobPrefixOnQiniu generates the prefix string of the job on qiniu
 func (j *Job) JobPrefixOnQiniu() string {
 	return path.Join("pr-logs", "pull", j.Org+"_"+j.RepoName, j.PRNumStr, j.JobName, j.BuildId)
 }
 
+// HtmlProfile generates the name of the profile html file
 func (j *Job) HtmlProfile() string {
 	return fmt.Sprintf("%s-%s-pr%s-coverage.html", j.Org, j.RepoName, j.PRNumStr)
 }
 
+// SetDeltaCovLinks set DeltaCovLinks to the job
 func (j *Job) SetDeltaCovLinks(c cover.DeltaCovList) {
 	c.Sort()
 	for i := 0; i < len(c); i++ {
diff --git a/pkg/qiniu/client.go b/pkg/qiniu/client.go
index d3255b8..e0c8918 100644
--- a/pkg/qiniu/client.go
+++ b/pkg/qiniu/client.go
@@ -139,12 +139,14 @@ func (q *QnClient) GetAccessURL(key string, timeout time.Duration) string {
 	return storage.MakePrivateURL(qbox.NewMac(q.cfg.AccessKey, q.cfg.SecretKey), q.cfg.Domain, key, deadline)
 }
 
+// LogHistoryTemplate is the template of the log history
 type LogHistoryTemplate struct {
 	BucketName string
 	KeyPath    string
 	Items      []logHistoryItem
 }
 
+// logHistoryItem represents a log history item
 type logHistoryItem struct {
 	Name string
 	Size string
@@ -152,7 +154,7 @@ type logHistoryItem struct {
 	Url  string
 }
 
-// Artifacts lists all artifacts available for the given job source
+// GetArtifactDetails lists all artifacts available for the given job source
 func (q *QnClient) GetArtifactDetails(key string) (*LogHistoryTemplate, error) {
 	tmpl := new(LogHistoryTemplate)
 	item := logHistoryItem{}
@@ -193,6 +195,7 @@ func timeConv(ptime int64) string {
 	return tm.Format("2006-01-02 03:04:05 PM")
 }
 
+// ListSubDirs list all the sub directions of the prefix string in qiniu client
 func (q *QnClient) ListSubDirs(prefix string) ([]string, error) {
 	var dirs []string
 	var marker string
diff --git a/pkg/qiniu/mock.go b/pkg/qiniu/mock.go
index 3aea357..c1a28f2 100644
--- a/pkg/qiniu/mock.go
+++ b/pkg/qiniu/mock.go
@@ -98,7 +98,7 @@ func MockRouterListAllAPI(router *httprouter.Router, count int) {
 		logrus.Infof("request url is: %s", r.URL.String())
 
 		if timeout > 0 {
-			timeout -= 1
+			timeout--
 			http.Error(w, "not found", http.StatusNotFound)
 			return
 		}
@@ -136,7 +136,7 @@ func MockPrivateDomainUrl(router *httprouter.Router, count int) {
 		logrus.Infof("request url is: %s", r.URL.String())
 
 		if timeout1 > 0 {
-			timeout1 -= 1
+			timeout1--
 			http.Error(w, "not found", http.StatusNotFound)
 			return
 		}
@@ -148,7 +148,7 @@ func MockPrivateDomainUrl(router *httprouter.Router, count int) {
 		logrus.Infof("request url is: %s", r.URL.String())
 
 		if timeout2 > 0 {
-			timeout2 -= 1
+			timeout2--
 			if timeout2%2 == 0 {
 				http.Error(w, "not found", 571)
 			} else {


Test patch:
diff --git a/pkg/build/tmpfolder_test.go b/pkg/build/tmpfolder_test.go
index 07614be..2183280 100644
--- a/pkg/build/tmpfolder_test.go
+++ b/pkg/build/tmpfolder_test.go
@@ -144,6 +144,7 @@ func TestFindWhereToInstall(t *testing.T) {
 		OriGOPATH: "",
 	}
 	placeToInstall, err := b.findWhereToInstall()
+	assert.NoError(t, err)
 	expectedPlace := filepath.Join(os.Getenv("HOME"), "go", "bin")
 	assert.Equal(t, placeToInstall, expectedPlace)
 }
diff --git a/pkg/cover/client_test.go b/pkg/cover/client_test.go
index 23ea4bd..1693569 100644
--- a/pkg/cover/client_test.go
+++ b/pkg/cover/client_test.go
@@ -107,7 +107,7 @@ func TestClientAction(t *testing.T) {
 	}
 	for _, item := range profileItems {
 		// init server
-		res, err := client.InitSystem()
+		_, err = client.InitSystem()
 		assert.NoError(t, err)
 		// register server
 		res, err = client.RegisterService(item.service)
@@ -122,7 +122,7 @@ func TestClientAction(t *testing.T) {
 	}
 
 	// init system and check service again
-	res, err = client.InitSystem()
+	_, err = client.InitSystem()
 	assert.NoError(t, err)
 	res, err = client.ListServices()
 	assert.NoError(t, err)
diff --git a/pkg/github/github_test.go b/pkg/github/github_test.go
index 6b4aa57..ffe7d1f 100644
--- a/pkg/github/github_test.go
+++ b/pkg/github/github_test.go
@@ -121,7 +121,7 @@ func TestCreateGithubComment(t *testing.T) {
 	router.HandlerFunc("DELETE", "/repos/qiniu/goc/issues/comments/1", func(w http.ResponseWriter, r *http.Request) {
 	})
 
-	p := GithubPrComment{
+	p := GitPrComment{
 		RobotUserName: "qiniu-bot",
 		RepoOwner:     "qiniu",
 		RepoName:      "goc",
@@ -136,7 +136,7 @@ func TestCreateGithubComment(t *testing.T) {
 }
 
 func TestCreateGithubCommentError(t *testing.T) {
-	p := &GithubPrComment{}
+	p := &GitPrComment{}
 	err := p.CreateGithubComment("", cover.DeltaCovList{})
 	assert.NoError(t, err)
 }
@@ -152,7 +152,7 @@ func TestGetPrChangedFiles(t *testing.T) {
 		fmt.Fprint(w, `[{"filename":"src/qiniu.com/kodo/s3apiv2/bucket/bucket.go"}]`)
 	})
 
-	p := GithubPrComment{
+	p := GitPrComment{
 		RobotUserName: "qiniu-bot",
 		RepoOwner:     "qiniu",
 		RepoName:      "goc",
@@ -168,7 +168,7 @@ func TestGetPrChangedFiles(t *testing.T) {
 }
 
 func TestGetCommentFlag(t *testing.T) {
-	p := GithubPrComment{
+	p := GitPrComment{
 		CommentFlag: "flag",
 	}
 	flag := p.GetCommentFlag()
diff --git a/pkg/qiniu/object_test.go b/pkg/qiniu/object_test.go
index 8ab9d83..f6d8427 100644
--- a/pkg/qiniu/object_test.go
+++ b/pkg/qiniu/object_test.go
@@ -54,6 +54,7 @@ func TestNewRangeReader(t *testing.T) {
 	assert.Equal(t, err, nil)
 
 	bodyBytes, err := ioutil.ReadAll(body)
+	assert.NoError(t, err)
 	assert.Equal(t, string(bodyBytes), "mock server ok")
 
 	// test with HEAD method
@@ -61,6 +62,7 @@ func TestNewRangeReader(t *testing.T) {
 	assert.Equal(t, err, nil)
 
 	bodyBytes, err = ioutil.ReadAll(body)
+	assert.NoError(t, err)
 	assert.Equal(t, string(bodyBytes), "")
 
 }
@@ -92,6 +94,7 @@ func TestNewRangeReaderWithTimeoutAndRecover(t *testing.T) {
 	assert.Equal(t, err, nil)
 
 	bodyBytes, err := ioutil.ReadAll(body)
+	assert.NoError(t, err)
 	assert.Equal(t, string(bodyBytes), "mock server ok")
 
 	// test with retry with statuscode=571, 573
@@ -100,6 +103,7 @@ func TestNewRangeReaderWithTimeoutAndRecover(t *testing.T) {
 	assert.Equal(t, err, nil)
 
 	bodyBytes, err = ioutil.ReadAll(body)
+	assert.NoError(t, err)
 	assert.Equal(t, string(bodyBytes), "mock server ok")
 }
 
diff --git a/tests/samples/multi_mains_project_with_internal/foo/bar1.go b/tests/samples/multi_mains_project_with_internal/foo/bar1.go
index f0bef31..76f5b0e 100644
--- a/tests/samples/multi_mains_project_with_internal/foo/bar1.go
+++ b/tests/samples/multi_mains_project_with_internal/foo/bar1.go
@@ -5,6 +5,7 @@ import (
 	"example.com/multi-mains-project/foo/internal/qiniu"
 )
 
+// Bar1 is a sample service
 func Bar1() {
 	internal.Xiaohong()
 	qiniu.BB()
diff --git a/tests/samples/multi_mains_project_with_internal/foo/bar2.go b/tests/samples/multi_mains_project_with_internal/foo/bar2.go
index 40dfd43..c893fab 100644
--- a/tests/samples/multi_mains_project_with_internal/foo/bar2.go
+++ b/tests/samples/multi_mains_project_with_internal/foo/bar2.go
@@ -5,6 +5,7 @@ import (
 	"example.com/multi-mains-project/foo/internal/qiniu"
 )
 
+// Bar2 is a sample service
 func Bar2() {
 	internal.Xiaohong()
 	qiniu.BB()
diff --git a/tests/samples/multi_mains_project_with_internal/foo/internal/qiniu/xiaoda.go b/tests/samples/multi_mains_project_with_internal/foo/internal/qiniu/xiaoda.go
index 482e5bc..2d11189 100644
--- a/tests/samples/multi_mains_project_with_internal/foo/internal/qiniu/xiaoda.go
+++ b/tests/samples/multi_mains_project_with_internal/foo/internal/qiniu/xiaoda.go
@@ -1,5 +1,6 @@
 package qiniu
 
+// BB is a internal function
 func BB() {
 
 }
diff --git a/tests/samples/multi_mains_project_with_internal/foo/internal/xiaoming.go b/tests/samples/multi_mains_project_with_internal/foo/internal/xiaoming.go
index bf0d355..6d36972 100644
--- a/tests/samples/multi_mains_project_with_internal/foo/internal/xiaoming.go
+++ b/tests/samples/multi_mains_project_with_internal/foo/internal/xiaoming.go
@@ -1,5 +1,6 @@
 package internal
 
+// Xiaohong is a internal sample function
 func Xiaohong() {
 
 }
diff --git a/tests/samples/multi_mains_project_with_internal/internal/foo.go b/tests/samples/multi_mains_project_with_internal/internal/foo.go
index 90912fc..a9090e2 100644
--- a/tests/samples/multi_mains_project_with_internal/internal/foo.go
+++ b/tests/samples/multi_mains_project_with_internal/internal/foo.go
@@ -2,6 +2,7 @@ package internal
 
 import "fmt"
 
+// Hello is a internal function
 func Hello() {
 	fmt.Println("hello, world.")
 }
diff --git a/tests/samples/simple_gopath_project/src/qiniu.com/simple_gopath_project/modulea/foo.go b/tests/samples/simple_gopath_project/src/qiniu.com/simple_gopath_project/modulea/foo.go
index 7b69ca4..7dcf1a0 100644
--- a/tests/samples/simple_gopath_project/src/qiniu.com/simple_gopath_project/modulea/foo.go
+++ b/tests/samples/simple_gopath_project/src/qiniu.com/simple_gopath_project/modulea/foo.go
@@ -1,5 +1,6 @@
 package modulea
 
+// Bar is a sample service
 func Bar() {
 
 }
diff --git a/tests/samples/simple_project_with_internal/foo/bar1.go b/tests/samples/simple_project_with_internal/foo/bar1.go
index e0eeaee..ab05dd8 100644
--- a/tests/samples/simple_project_with_internal/foo/bar1.go
+++ b/tests/samples/simple_project_with_internal/foo/bar1.go
@@ -5,6 +5,7 @@ import (
 	"example.com/simple-project/foo/internal/qiniu"
 )
 
+// Bar1 is a sample service
 func Bar1() {
 	internal.Xiaohong()
 	qiniu.BB()
diff --git a/tests/samples/simple_project_with_internal/foo/bar2.go b/tests/samples/simple_project_with_internal/foo/bar2.go
index 7ec60a1..060e874 100644
--- a/tests/samples/simple_project_with_internal/foo/bar2.go
+++ b/tests/samples/simple_project_with_internal/foo/bar2.go
@@ -5,6 +5,7 @@ import (
 	"example.com/simple-project/foo/internal/qiniu"
 )
 
+// Bar2 is a sample service
 func Bar2() {
 	internal.Xiaohong()
 	qiniu.BB()
diff --git a/tests/samples/simple_project_with_internal/foo/internal/qiniu/xiaoda.go b/tests/samples/simple_project_with_internal/foo/internal/qiniu/xiaoda.go
index 482e5bc..2d11189 100644
--- a/tests/samples/simple_project_with_internal/foo/internal/qiniu/xiaoda.go
+++ b/tests/samples/simple_project_with_internal/foo/internal/qiniu/xiaoda.go
@@ -1,5 +1,6 @@
 package qiniu
 
+// BB is a internal function
 func BB() {
 
 }
diff --git a/tests/samples/simple_project_with_internal/foo/internal/xiaoming.go b/tests/samples/simple_project_with_internal/foo/internal/xiaoming.go
index bf0d355..0f225c4 100644
--- a/tests/samples/simple_project_with_internal/foo/internal/xiaoming.go
+++ b/tests/samples/simple_project_with_internal/foo/internal/xiaoming.go
@@ -1,5 +1,6 @@
 package internal
 
+// Xiaohong is a internal function
 func Xiaohong() {
 
 }
diff --git a/tests/samples/simple_project_with_internal/internal/foo.go b/tests/samples/simple_project_with_internal/internal/foo.go
index 90912fc..a9090e2 100644
--- a/tests/samples/simple_project_with_internal/internal/foo.go
+++ b/tests/samples/simple_project_with_internal/internal/foo.go
@@ -2,6 +2,7 @@ package internal
 
 import "fmt"
 
+// Hello is a internal function
 func Hello() {
 	fmt.Println("hello, world.")
 }